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 %>

  

select_tag in rails about selected not change and onchange()的更多相关文章

  1. change和onchange触发为什么不立马生效?

    change和onchange触发了,为什么不立马生效?那是因为他们本身不是当文本改变就立马触发的事件,而是当文本改变了,blur离开了表单才触发. 如果要加上触发请结合keyup,keydown,o ...

  2. change和onchange、click和onclick的区别

    change和onchange.click和onclick的区别: onchange和onclick都是js方法 可以在标签元素上使用  <input  onchange="" ...

  3. change和onChange

    change是jquery上的绑定事件,可用于下拉框动态关联数据: $(function(){ $("#id").change(function(e){ alert($(this) ...

  4. [NPM] Run npm scripts when files change with onchange

    In this lesson we will look at how we can setup our npm scripts to execute when the file system has ...

  5. Rails当你运行一个数据库回滚错误:ActiveRecord::IrreversibleMigration exception

    最近rails3.2在更改数据库表字段,然后要回滚取消,但在运行rake db:rollback命令,错误: rake aborted! An error has occurred, all late ...

  6. js设置下拉框选中后change事件无效解决

    下拉框部分代码: <select id="bigType"> <option value="">请选择</option> & ...

  7. [No00006A]Js的addEventListener()及attachEvent()区别分析【js中的事件监听】

    1.添加时间监听: Chrom中: addEventListener的使用方式: target.addEventListener(type, listener, useCapture); target ...

  8. extjs后自己写了一些见不得人的脚本

    <html> <head> <title> 配置管理器 </title> <style type="text/css"> ...

  9. EUI ViewStack实现选项卡组件

    一  TabBar+ViewStack实现 这个教程确实没看懂...贼麻烦... 二 RadioButton+ViewStack 在exml中拖动组件RadioButton和ViewStack 设置e ...

随机推荐

  1. Slip.js – 在触摸屏上实现列表的滑动排序功能

    Slip.js 是一个很小的 JavaScript 库,用于实现对触摸屏的互动 Swipe 和对元素重新排序列表(Reordering).Slip.js 没有任何的依赖,你可以通过自定义 DOM 事件 ...

  2. 在ubuntu下创建wifi供移动端使用

    转自:http://jingyan.baidu.com/album/ea24bc39b03fc6da62b331f0.html?picindex=8 完全正确是流程 另外 还需要本机能够连上内网的vp ...

  3. MVC学习笔记索引帖

    [MVC学习笔记]1.项目结构搭建及单个类在各个层次中的实现 [MVC学习笔记]2.使用T4模板生成其他类的具体实现 [MVC学习笔记]3.使用Spring.Net应用IOC(依赖倒置) [MVC学习 ...

  4. Python入门版

    一.前言 陆陆续续学习Python已经近半年时间了,感觉到Python的强大之外,也深刻体会到Python的艺术.哲学.曾经的约定,到现在才兑现,其中不乏有很多懈怠,狼狈. Python入门关于Pyt ...

  5. wpf 查找页面的所有TextBox

    private void EnumVisual(Visual myVisual) { for (int i = 0; i < VisualTreeHelper.GetChildrenCount( ...

  6. [转]微信公众平台WeChat PHP SDK

    地址:https://github.com/dodgepudding/wechat-php-sdk 微信公众平台php开发包,细化各项接口操作,支持链式调用 微信支付接入文档: https://mp. ...

  7. 解决Cannot change version of project facet Dynamic Web M

    dynamic web module 版本之间的区别: Servlet 3.0 December 2009 JavaEE 6, JavaSE 6 Pluggability, Ease of devel ...

  8. SignalR-入门

    1.什么是SignalR: ASP.NET SignalR是为简化开发开发人员将实时web内容添加到应用程序过程而提供的类库.实时web功能指的是让服务器代码可以随时主动推送内容给客户端,而不是让服务 ...

  9. [PE结构分析] 6.IMAGE_SECTION_HEADER

    IMAGE_SECTION_HEADER 的源代码如下: typedef struct _IMAGE_SECTION_HEADER { BYTE Name[IMAGE_SIZEOF_SHORT_NAM ...

  10. redis3.0 集群实战3 - java编程实战

    本文主要描述使用jedis进行redis-cluster操作   jedis jedis是redis官方推荐使用的java redis客户端,github地址为,https://github.com/ ...