AKor
AKor

Reputation: 8882

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.

Upvotes: 1

Views: 69

Answers (2)

venimus
venimus

Reputation: 6047

you should handle the form's onsubmit event

and put $('#foo').val($('#currencySelect').val());

Upvotes: 1

Elias Zamaria
Elias Zamaria

Reputation: 101083

$("#foo").val($("#currencySelect").val());

Upvotes: 0

Related Questions