Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Enable/Disable form elements

Thread Tools

Enable/Disable form elements

Age Bosma
Posts: n/a

I've got a serie of radio options in a form, if the last option gets
selected I want it to Enable a different (text) form field.
Is it possible to monitor if a radio button in a form get's unselected
instead of supplying the same piece of JavaScript code for each other
radio option?


<legend><b>7. Are you still alive?</b></legend>
<input type="radio" name="q7" value="yes"
onclick="document.surveyform.nocodec7.disabled=tru e;" />Yes<br />
<input type="radio" name="q7" value="abit"
onclick="document.surveyform.nocodec7.disabled=tru e;" />A little bit<br />
<input type="radio" name="q7" value="no"
onclick="document.surveyform.nocodec7.disabled=fal se;" />No, because:
<input type="text" name="reason7" disabled />

Now, in this example the text field is Disabled by default, if the
option "No" is selected this field gets activated.
If any of the other options are selected it will Disable the text field
Although this is perfectly working I'm interested to know if it isn't
just possible to execute some piece of code as soon as option "No"
becomes deselected.

Age Bosma

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
newb: recurse over elements children and disable all form elements Javascript 4 09-20-2006 07:42 AM
struts indexed form elements not getting into form bean Java 1 01-07-2006 09:29 PM
Form images don't appear in form.elements Howard Jess Javascript 1 10-18-2004 07:15 PM
Does form.disable work on hidden text form elements? Mark Hannon Javascript 3 09-02-2004 11:37 PM
File uploading from a form with textbox form elements Andy Johns ASP .Net 2 03-02-2004 06:21 AM