rails submit

onClick改变js时间

<form>
<%=submit_tag "礼品配送", :name => "gift",:class=>"button" ,  nClick => "document.myaccs.form_action.value='gift' "%>
<input type="text" id="cad_gift_list" name="cad_gift_list">
</form>

做选项内容改变时触发事件
<form  name="form" action= "/search_by_object" method="get" >
<select name="object" onchange ="document.form.submit();">
<option value=''>选择负责对象</option>
<%=options_from_collection_for_select(CadUser.find(:all), "id", "name",     params[:object].to_i)%>
</select>  
  </form>

cad_user=CadUser.find_or_create_by_name(params["user"+i.to_s])
rails自带的find_or_create_by_name语句表示有则查找,没有则新增。

你可能感兴趣的:(button,submit)