随笔-167  评论-65  文章-0  trackbacks-0

js改变下拉框的显示

<select name="s" id="s">
<OPTION VALUE="1">1</OPTION>
<OPTION value="2">2</OPTION>
<OPTION value="3">3</OPTION>
</select>

<script type="text/javascript">
s.options[0].selected=true  //方法1
s.selectedIndex=1; //方法2
document.getElementById('ss').selectedIndex=1;  //方法3,建议使用这个方法
</script>

ref:

http://www.javascriptkit.com/jsref/select.shtml

js验证为正整数

<script>
var re = /^[1-9]d*$/;   //智能验证单个字符

if (!re.test(document.getElementById('group_order').value)){
   alert("组排序必须为数字!");
   document.getElementById('group_order').focus();
   return false;
}


</script>

 

 

if(value <0  ||  value!=parseInt(value) ){
       alert("不是正整数");
}else{
       alert("是正整数");
}

js发送表单(方法一): check_input 是js函数,但是这个方法会把页面内所有的表单都发送掉

  <% form_tag( {:controller=>"transaction",:action=>"check_cid"},{:name=>"form1",:method=>"post",:multipart=>"true" ,:onsubmit=>”return check_input();”}) do %>

            <% end %>

js发送表单(方法二):  check_original 是js函数,这个方法会发送指定的form,无论方法一,方法二 都别忘了 前面加 return

  <%= form_tag({:controller=>"program",:action=>"index"},{:name=>"newform",:method=>"post",:multipart=>"true"})  %>    
<%= submit_tag "添加",{:name=>'newgroup',:onclick=>'return check_original();'}  %>
  <%= form_tag %>

待续................



write by feng
posted on 2009-04-16 19:40 fl1429 阅读(301) 评论(0)  编辑  收藏 所属分类: Ajax

只有注册用户登录后才能发表评论。


网站导航:
 
已访问数:
free counters