psharma
psharma

Reputation: 1289

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 %>

Upvotes: 0

Views: 1511

Answers (1)

rahul maindargi
rahul maindargi

Reputation: 5625

Assume

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

then

you need below code

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

Upvotes: 1

Related Questions