jQuery: using select onchange event to fill sibling text field?

Posted by gsquare567 on Stack Overflow See other posts from Stack Overflow or by gsquare567
Published on 2010-06-18T16:10:21Z Indexed on 2010/06/18 16:13 UTC
Read the original article Hit count: 329

Filed under:
|
<select onchange="$(self).siblings('input[type=text]').val( $(self).val() ); $(self).siblings('input[type=checkbox]').attr('checked','checked')">

that does not work

before the select box, there are these inputs (examples):

<input type="text" value="" id="product[14][value]" name="product[14][value]">
<input type="checkbox" value="1" id="product[14][enabled]" name="product[14][enabled]">

after debugging in firebug, i found that it is in fact finding the siblings, and the part that is failing is filling the text field with the select's value:

.val( $(self).val() ); 

what's wrong with it? thanks!

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about select