Results 1 to 2 of 2

Thread: save undefined value from checkbox

  1. #1
    Join Date
    Sep 2010
    Posts
    188

    save undefined value from checkbox

    Hi..

    I have checkbox and I need to get his value.

    I create function for checkbox if checkbox is clicked it is true then the checkbox value is H else W.

    Code:
    function chk(){
     
    if(document.getElementById('H').checked==true){
     var H = document.getElementById('H'). value = H;
    }
    
    else if(document.getElementById('H').checked==false){
    var H = document.getElementById('H'). value = W;
    }
     
    }
    and I have function for save :

    Code:
    function ApproveLeaveOP(){
        var H = document.getElementById('H').value;
        document.sampleform.action="AddLeave.php?H="+H;
        document.sampleform.submit();  
    
    }
    <input type="checkbox" name="H" id="H" value="" onclick="chk()">
    I don't know how can I add value to the checkbox if I click the value will be H if not the value is W.

    I am new in using checkbox.
    Thank you so much..

  2. #2
    Join Date
    Apr 2012
    Posts
    8
    In function chk() you are assigning non-literal values (H and W) to the variable H. Are H and W defined somewhere?

Similar Threads

  1. getting undefined using $_GET function
    By newphpbees in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 0
    Last Post: 02 Jan 2012, 07:35 PM
  2. SWFObject is undefined
    By RoyalPegasus in forum Web Design, HTML Reference and CSS
    Replies: 0
    Last Post: 27 Feb 2010, 07:16 PM

Posting Permissions

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