Getting value of hidden field

hi
in my rhtml file i have

<%= hidden_field_tag 'fc', 42, :id=>'fc' %>

how can i set params[:blah] to have the value of fc, so i can access the
value of fc through params[:blah] in my controller ?

thank you

Francis S. wrote:

Lalala L. wrote:

hi
in my rhtml file i have

<%= hidden_field_tag 'fc', 42, :id=>'fc' %>

how can i set params[:blah] to have the value of fc, so i can access the
value of fc through params[:blah] in my controller ?

thank you

well, you have to change this:

<%= hidden_field_tag ‘blah’, 42, :id=>‘fc’ %>

to access it as params[:blah] in your controller.

Hope that helps:)

<%= hidden_field_tag 'fc1', 42, :id=>'fc2' %> what if I want to fill the value using javascript? Let's say instead of 42, I want the return value of js() to be the value of this hidden field. Is there a way of doing this?

Usually using javascript I can access a hidden field value using:
document.formName.fieldName.value. Please correct me, in this case the
formName = par2 and what is the fieldName ? Is it fc1 or fc2?
Let’s say it is fc1, when I do document.par2.fc1.value = 12, Will 12 be
the value of params[:fc1] in my controller?

I come up to this question because I want to pass value from javascript
to ruby, and thinking that I can just put the javascript value to hidden
field and let rails grab the value from hidden field

Thank you for replying

Lalala L. wrote:

hi
in my rhtml file i have

<%= hidden_field_tag 'fc', 42, :id=>'fc' %>

how can i set params[:blah] to have the value of fc, so i can access the
value of fc through params[:blah] in my controller ?

thank you

well, you have to change this:

<%= hidden_field_tag ‘blah’, 42, :id=>‘fc’ %>

to access it as params[:blah] in your controller.

Hope that helps:)