I have the following HTMl:
<input id="brandID" name="brandID" type="hidden" value="" />
<select id="selectList" class="textfield70pc" name="selectList">
<option selected="" value="221">A</option>
<option value="4673">B</option>
</select>
Upon changing the value of a select box, I need to populate this input field.
I’ve tried something like this, but it’s not working.
jQuery('#selectList').change(function(){
jQuery('#brandID').attr('value', '123123');
});
Suggestions anyone?
Update
This works though:
document.getElementById('brandID').value = '123'
But I would like to use jQuery.
Change is not supported in jQuery live
If you want to use live, use live query
EDIT: Your code above should work as it is, so maybe your selectList is formatted improperly?
This basic HTML made the above function work for me:
Hmmm maybe you’re just not seeing it update the HTML, but it does update the DOM (are you using firebug?) I added an alert to show the value and it showed the correct value