Jquery中文网 www.jquerycn.cn
Jquery中文网 >  脚本编程  >  javascript  >  正文 js 控制select 多选框的选择个数

js 控制select 多选框的选择个数

发布时间:2017-07-16   编辑:www.jquerycn.cn
jquery中文网为您提供js 控制select 多选框的选择个数等资源,欢迎您收藏本站,我们将为您提供最新的js 控制select 多选框的选择个数资源
提示:您可以先修改部分代码再运行

<textarea name="runcool" rows="28" cols="75" > <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>js 控制多选框的选择个数</title> <meta http-equiv="content-type" content="text/html;charset=gb2312"> </head> <body> 最多只能选择三项: 一班 二班 三班 四班
<script language="javascript"> function setText(){ var objs = document.registerfm.checkbox; var checkedCount=0; for(var i=0;i<objs.length;i ){ if(objs[i].checked) checkedCount ; } if(checkedCount>2){ alert("最多只能选择三项!"); return false; } var values=[]; for(var i=0;i<objs.length;i ){ if(objs[i].checked) values[values.length]=objs[i].value; } document.registerfm.checkbox.value=values.join(','); }
提示:您可以先修改部分代码再运行

您可能感兴趣的文章:
js判断复选框checkbox是否选中并取出值
jQuery select操作控制方法小结
JQuery 常用操作代码
探讨JavaScript的选择框脚本
Jquery 获取表单text,areatext,radio,checkbox,select值的代码
js 限定复选框选择个数的例子
jQuery转换选择框为按钮的插件 Select2Buttons
jQuery获取Select选择的Text和Value(详细汇总)
Jquery获取Select下拉框中Text与Value的方法详解
jQuery获取Select中Text与Value值

[关闭]