Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] Disabled property for input
- From: javascript@xxxxxxxxxx (Harry Love)
- Subject: [Javascript] Disabled property for input
- Date: Mon, 19 Aug 2002 10:07:23 -0700
Oops, meant to say that when the option is "Done" the box is enabled, anything else is disabled. Sorry for the confusion, Harry -----Original Message----- From: javascript-admin@xxxxxxxxxx [mailto:javascript-admin@xxxxxxxxxx] On Behalf Of Harry Love Sent: Monday, August 19, 2002 9:58 AM To: javascript@xxxxxxxxxx Subject: RE: [Javascript] Disabled property for input Is this what you're talking about? The following works in d.getElementById() capable browsers. Alternatively, you could use the document.forms[] array. In the version below, when a user changes the select box to "Done," the "Completed Date" input is disabled. If the user selects any other option, the input box is enabled. I also added a style change for an added visual cue that the box is enabled or disabled. <script type="text/javascript" language="JavaScript"> var d = document; function enableField() { if(d.getElementById("status").value == "Done") { d.getElementById("completedDate").disabled = false; d.getElementById("completedDatePara").style.color = "#000"; } else { d.getElementById("completedDate").disabled = true; d.getElementById("completedDate").value = ""; d.getElementById("completedDatePara").style.color = "#999"; } } </script> </head> <body> <form> <p>Status<br /> <select onchange="enableField()" name="status" id="status"> <option value="Standby">Standby</option> <option value="In Progress">In Progress</option> <option value="On Hold">On Hold</option> <option value="Done">Done</option> </select> </p> <p id="completedDatePara">Completed Date<br /> <input type="text" id="completedDate" name="completedDate" value="" /> </p> </form> </body> </html> Regards, Harry _______________________________________________ Javascript mailing list Javascript@xxxxxxxxxx https://lists.LaTech.edu/mailman/listinfo/javascript
- References:
- [Javascript] Disabled property for input
- From: Harry Love
- [Javascript] Disabled property for input
- Prev by Date: [Javascript] Disabled property for input
- Next by Date: [Javascript] RE: function not defined only in Netscape 6
- Previous by thread: [Javascript] Disabled property for input
- Next by thread: [Javascript] Disabled property for input
- Index(es):