简体   繁体   中英

Pass value from jquery to rails form's hidden_field

I have jquery which renders a value inside an html element

<div id="serialsNewFormatted"></div>

Which is nothing but a number/integer. Now I want to pass value rendere inside the above code into my form's hidden_field .

How do I do it?

Thanks

UPDATE: I need to pass the value inside the rails form hidden field, something like <%= f.hidden_field :data, :value => ValueGoesHere %>

Assume

<input type="hidden" id="hiddenObject"/>

then

you need below code

 $("#hiddenObject").val($("#serialsNewFormatted").html());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM