开发者

Getting a value from Javascript on Ruby

<td 开发者_开发技巧class="run_time"><%= l.text_field :run_time, :class => "line_item_run_time" %></td>

Hello.

I have rhtml code, l.text_field :run_time, has a value in its textbox that I need to use and I want to store it in a variable, if for example I do variable = l.text_field :run_time, it is going to save the whole object, the textbox with the value inside. Right now I just need the number that is inside.

Could you please tell me how can I do this it Ruby. Thanks


It's not clear what you're asking for, but if you want the value from the object, what you might want is this:

variable = l.object.run_time

That calls the run_time method on the currently bound form object l.


If its a textfield, it would be part of a form, which you will eventually post to the server, sending to the server all the data for the fields in the form.
The call may be a redirect_call or an AJAX call, but the data would be sent to the server.
The action that you send the data to, will receive the data in a params hash, and then you can get the value of the text field.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜