Set value of input
<p>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.</p>

<pre><code>&lt;td id="check-box"&gt;&lt;input type="checkbox" name="checkbox"&gt;&lt;/td&gt;
&lt;td id="qty-box"&gt;&lt;input type="text" name="qtybox"&gt;&lt;/td&gt;

&lt;script type="text/javascript"&gt;
function setValue(a) {
   if (a &lt; 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;
    }
});
&lt;/script&gt;
</code></pre>
