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
    New Coder
    Join Date
    Jul 2006
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Fustrating (but simple?!) problem, checking checkboxes

    Hey all!

    I've been doing a lot of php coding recently, but have come to the point where I want to add some javascript.. and I'm not having much luck!

    I think the blow code explains what I'm trying to do, but where am I going wrong?

    I actually had something far more complicated than this (to do more tasks) but I cut it down to this to try and get it working from a very low level, then build it up..

    Any help would be greatly appreciated!

    Code:
    <script language="Javascript">
    <!--
    function testScript() {
    	document.myform.mycheckbox.selected = true;
    }	
    -->
    </script>
    <a href="#" onClick="testScript()">Check</a>
    
    <form name="myform" action="" method="post">
      <input type="checkbox" name="mycheckbox" value="1">
    </form>

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Use

    document.myform.mycheckbox.checked = true;
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.

  • #3
    New Coder
    Join Date
    Jul 2006
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    *bangs head on table*

    Thanks


  •  

    Posting Permissions

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