I'm trying to set the input value to 1 when checking the checkbox and empty when unchecking, Can't get it to work, please help.
<td id="check-box"><input type="checkbox" name="checkbox"></td>
<td id="qty-box"><input type="text" name="qtybox"></td>
<script type="text/javascript">
function setValue(a) {
if (a < 1) {
a = 1;
}
}
var qty = $('#qty-box [name="qtybox"]').val();
$("#check-box").click(function() {
if ($(this[name = "checkbox"]).attr('checked', true)) {
setValue(qty);
}
else {
qty = 0;
}
});
</script>