新手问题 怎样去获得输入框里的值?

babywhy · May 15, 2013 · Last by babywhy replied at May 16, 2013 · 2582 hits

本 rails 程序有视图、控制台,并没有模型。视图:

Hello From Rails!!!

It is <%= @time %>

您想查询第几篇论文题录?

Time to say <%= link_to "查询",chaxun_chengxian_path %>

首先在输入框输入范围内的数字,点击“查询”转到 chaxun/chengxian 方法,怎样获取输入框里的值并传到 chengxian 方法里呢? 小白求方法。

简单点就弄个 form_tag

回复 1 楼 @small fish <form name="frm"> <input type="text" name=“name” id=“id_name”..../> </form> 这样?

这这这。。。。

<%= form_tag chaxun_chengxian_path, :method => :get do %>
   <%= text_field_tag :search, params[:search]%>
   <%= submit_tag "查询" %>
<%end%>

回复 3 楼 @ChanceDoor 我爱你春天蓬勃的秧苗 !!我爱你秋日金黄的硕果!!!

You need to Sign in before reply, if you don't have an account, please Sign up first.