SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    checkbox button verification

    Hi all this should be simple, not sure why its not working..

    I have a checkbox in a form, onsubmit im trying to verify that is IS checked.... this is what I have and its not working...any ideas? Oh, the function IS being called, its just not verifying, the checkbox name ="agree"

    Thanks...

    PHP Code:
    <script>
    function 
    submitIt(theform){

        if (
    documenttheform.agree.checked){
            
    alert ("agreed");
            return 
    false
        
    }
    }
    </script> 

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    document. theform.agree.checked
    You can't see anything wrong with that? Hmm..I guess have spacing in the middle of a reference chain works after all.

    Post your html.

  3. #3
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It looks like you are passing the reference to the form, which would be something like this:

    document.my_form

    and then in the function you take that reference and put document in front of it, so you end up with:

    document.document.my_form

  4. #4
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    7stud good call thats EXACTLY what was happening thank you for your help....also is there anyway to check for 'unchecked'? i tried checked==null....

  5. #5
    SitePoint Addict
    Join Date
    May 2000
    Posts
    313
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try:
    if (theform.agree.checked==false)

  6. #6
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for your help guys. i feel like a noob.


Bookmarks

Posting Permissions

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