View Full Version : save undefined value from checkbox

11 Apr 2012, 11:37 PM

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.

function chk(){

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 :

function ApproveLeaveOP(){
var H = document.getElementById('H').value;

<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..

13 Apr 2012, 01:49 AM
In function chk() you are assigning non-literal values (H and W) to the variable H. Are H and W defined somewhere?