• select_tag in rails about selected not change and onchange()


    make it more easy after http://www.cnblogs.com/juandx/p/4058399.html

    1  if you want the selected is what you choose after you submit the form use javascripts, then you should do this  selected: params[:option] in options_for_select();

    2  if you want to submit after you change the select tag immediately,you should use onchange: "this.form.submit();"  ofcouse the ";"  is not necessary;

    <%= form_tag("monitor",:id => "idform",name: "idform",method: "get") do |f| %>
      时间间隔:
      <%= select_tag :times, options_for_select([["second","_10seconds"],["minute","_5minutes"],["hour","_hour"],["day","_day"],["week","_week"],["month","_month"],["year","_year"]] , selected: (params[:times]==nil ? "_5minutes" : params[:times]) ), onchange: "this.form.submit();" %>
            
      列数:
      <%= select_tag :col, options_for_select([["1","1"],["2","2"],["3","3"],["4","4"],["5","5"],["6","6"],["7","7"],["8","8"],["9","9"],["10","10"]], selected: (params[:col]==nil ? 2 : params[:col]) ), onchange: "this.form.submit();" %>
         
      <%= submit_tag("刷新") %>
    <% end %>
    

      

  • 相关阅读:
    申请加分项
    课程评价
    本周总结
    热词2
    热词1
    php大作业
    css网格布局
    php实验4
    本周总结
    css边框图像
  • 原文地址:https://www.cnblogs.com/juandx/p/4100905.html
Copyright © 2020-2023  润新知