Using jQuery to pull values from a select element
I have a select element in part of my page, and a form all the way on the bottom. I'm trying to populate 开发者_高级运维one of the form variables with the value of the select element like this:
<input type="hidden" value="valuefromselectelement..." name="foo" id="foo"/>
How can I do that? Presume the select element has the id currencySelect
.
you should handle the form's onsubmit
event
and put $('#foo').val($('#currencySelect').val());
$("#foo").val($("#currencySelect").val());
精彩评论