Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    May 2004
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Disabling fields

    How would I make it so if say an option field with yes or no is selected on yes in the current page, other fields become disabled in the current page based on what is selected.

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,043
    Thanks
    0
    Thanked 251 Times in 247 Posts
    <form>
    <input type="radio" name="answer" value="1" onclick="enableDisableFields(this)" />Yes
    <input type="radio" name="answer" value="0" onclick="enableDisableFields(this)" />No
    </form>

    function enableDisableFields(rad){
    var oForm = rad.form;
    var state = new Boolean(rad.value).valueOf(); //convert '1' to true and '0' to false
    oForm.theField.disabled=state;
    oForm.theField2.disabled=state;
    }


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •