jQuery get select option id and change hidden input value -


I have a form with a selection list; Every option also has a dynamic ID, which I need to capture And then it is used to change the value of the hidden input. So basically the selected option IDs and change the value of hidden input value.

Like my selection and hidden input:

  & lt; Name = select "item_options" id = "size" & gt; & Lt; Option value = "20030" id = "universal" & gt; Universal (20030) & lt; / Options & gt; & Lt; Option value = "4545456" id = "medium" & gt; Medium (4545456) & lt; / Options & gt; & Lt; Option value = "15447" id = "large" & gt; Big (15447) & lt; / Options & gt; & Lt; / Select & gt; & Lt; Input type = "hidden" name = "item_options_name" value = "universal" id = "changevalue" />  

I did some jQuery work to capture the ID of the selected option, but how can I use it to change the value of my input.

  $ ('# size'). Change (function () {var id = $ (this) .find (': selected') [0] .id; $ ('# changevalue'). Val (id);})  

Comments