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.

Reply via email to