Jquery
var g = $("#chav_wc:checked").val();
alert(g);
and.. HTML
<input type="checkbox" id="chav_wc" value="1" /></div>
Works fine, but if checkobx is not checked, returns value as “undefined”. How can I set it to return “0” instead when not checked? Thx.
EDIT (solution)
Solution if someone encounters same challenge (thx 2 Dave & insertusernamehere)..
var g = ($('#chav_wc').is(':checked') ? 1 : 0 );
have you tried: