If you're using the latest jQuery you don't need to have the @s in attribute selectors, and in this case you don't even need to use the attribute selectors at all, you can use the CSS id '#' selector. You could also drop the "input" at the start of the selectors if you only have "input" elements with the ids of "same", "input1" or "input0".
$(document).ready(function() { $('input#same').click(function() { // this == #same input element (not jQuery wrapped) // if checkbox is checked if ( this.checked ) { // copy the value of input0 and put it in input1 $('input#input1').val( $('input#input0').val() ); } }); }); Karl Rudd On Mon, Jun 2, 2008 at 11:41 AM, ryy705 <[EMAIL PROTECTED]> wrote: > > > Hello, > > I would like to copy the value of a text field(id=input0) to a different > text field(id=input1) when a checkbox(id=same, value=1) is checked off. I > am using the following code to do it. However, the value gets copied over > whenever the checkbox is clicked, it doesn't matter if its checked off or > not. How can I ensure that JQuery will only copy the value when the checkbox > is clicked AND there is a check mark present. I am new to JQuery so any > help would be appreciated. Many thanks in advance. > > $(document).ready(function() { > $('[EMAIL PROTECTED]"same"]').click(function() { > > //if checkbox is checked > if ($('[EMAIL PROTECTED]"same"]').val() == '1') { > > // copy the value of input0 and put it in input1 > $('[EMAIL PROTECTED]"input1"]').val($('[EMAIL > PROTECTED]"input0"]').val()); > } > }) > -- > View this message in context: > http://www.nabble.com/How-to-work-with-checkboxes-tp17582264s27240p17582264.html > Sent from the jQuery General Discussion mailing list archive at Nabble.com. > >