1. July 11

    and what about toggling more than one field by selecting only one checkbox?

  2. July 11

    I find the solution, separating by ,
    But what with radio buttons, they do not reset when leaving (becose no click!)

  3. SuryaPrakash rao PC
    August 22

    This is One of the Good Site to learn Javascript Quickly

  4. cp444
    October 27

    This doesn’t work in FireFox. Is there a work around?

  5. cp444
    October 27

    Sorry, it must be that I am applying this to a div tag I did this to disable multiple input tags. Can I apply it to multiple areas of the form in the one action?

  6. January 31

    A more elegant way to do the last line of toggle() would be instead of:
    updateToggle = checkbox.checked ? toggle.disabled=false : toggle.disabled=true;
    toggle.disabled= checkbox.checked;

    Then you could get rid of all the variables in the function:
    function toggle(checkboxId, toggleId) {
    document.getElementById(toggleId).disabled= document.getElementById(checkboxId).checked;

    Or, you can get rid of the method altogether:

  7. January 31

    Or, you can get rid of the method altogether:

    <input type=”checkbox” onclick=”this.form.disableMe.disabled=this.checked”/>

    <input type=”text” name=”disableMe”/>

  8. That was a really cool suggestion because it’s short, elegant and doesn’t require javascript code in the head, however it didn’t work for me…
    This did work for me:

    unfortunately it doesn’t toggle but at least it enables when the field is initially disabled (which is what I needed to do in my case)

    toggling would be nice though…

  9. April 22

    Awesome! This was exactly what I was looking for! All the other examples I found used ajax or jquery, this is so much simpler. Thank you!

Leave a Reply