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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Posts
    553
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Addressing checkbox in order to uncheck it

    I am creating a script called by an onClick event for a checkbox. Under certain conditions, I want to reset the checkbox to unchecked in the function. The checkbox that has been checked is one of many checkboxes all with the same name (each has a unique id). To set the value of the check box back to unchecked, how can I address the checkbox? I have tried, for instance, this.checked=false, but this does not work.

    G

  • #2
    Regular Coder Lerura's Avatar
    Join Date
    Aug 2005
    Location
    Denmark
    Posts
    945
    Thanks
    0
    Thanked 129 Times in 128 Posts
    Code:
    document.getElementById('checkboxID').checked=false;
    will do it.

    if you have stored the checkboxname in variable i.e. function Uncheck(box) it should be:

    Code:
    document.getElementById(box).checked=false;
    in the last example the checkbox's ID is called within the function onClick="Uncheck('checkboxID')"

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Posts
    553
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Awesome, thanks... I also got the following to work:

    onClick="callFunction(this,etc);"

    and in the script

    callFunction(obj,etc) {
    obj.checked=false;


    G


  •  

    Posting Permissions

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