Enable/Disable form elements

Discussion in 'Javascript' started by Age Bosma, Oct 10, 2003.

  1. Age Bosma

    Age Bosma Guest

    Hi,

    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?

    Situation:

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

    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
    again.
    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
     
    Age Bosma, Oct 10, 2003
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Patrick
    Replies:
    1
    Views:
    935
  2. Henrik Hjøllund Hansen

    Dynamically enable/disable an element inside a form.

    Henrik Hjøllund Hansen, Dec 18, 2003, in forum: HTML
    Replies:
    2
    Views:
    4,765
    Jukka K. Korpela
    Dec 19, 2003
  3. Shabam

    Disable/Enable Form

    Shabam, Feb 29, 2004, in forum: Javascript
    Replies:
    1
    Views:
    173
    Randy Webb
    Feb 29, 2004
  4. Mark Hannon
    Replies:
    3
    Views:
    302
    Randy Webb
    Sep 3, 2004
  5. joe t.
    Replies:
    3
    Views:
    288
    Michael Winter
    Mar 17, 2005
  6. prisk

    enable/disable dynamic form elements

    prisk, Sep 16, 2006, in forum: Javascript
    Replies:
    0
    Views:
    202
    prisk
    Sep 16, 2006
  7. Replies:
    4
    Views:
    375
  8. Kevin Blount
    Replies:
    27
    Views:
    457
    Richard Maher
    Sep 13, 2009
Loading...