复选框控制超过限制即弹出警告框
2015-07-02 15:15
453 查看
<html> <title>复选框限制,超过限制即弹出警告框丨任e行行车记录仪</title> <body> <SCRIPT LANGUAGE="JavaScript"> <!--// function countChoices(obj) { max = 2; box1 = obj.form.box1.checked; box2 = obj.form.box2.checked; box3 = obj.form.box3.checked; count = (box1 ? 1 : 0) + (box2 ? 1 : 0) + (box3 ? 1 : 0); if (count > max) { alert("对不起,你只能选择" + max + "个项目!"); obj.checked = false; } } //--> </script> <form name="form"> 请最多选择2个项目: <p> <input type=checkbox name=box1 onClick="countChoices(this)"> 选择项目1 <p> <input type=checkbox name=box2 onClick="countChoices(this)"> 选择项目2 <p> <input type=checkbox name=box3 onClick="countChoices(this)"> 选择项目3 <p> <div> </div> </FORM> </body> </html> <br><br><hr>
相关文章推荐
- MongoDB应用——GridFS存储文件
- SQL语句的语法-Data Definition Statements
- oracle等待事件buffer exterminate
- 黑马程序员----OC学习笔记之属性学习
- Apache JMeter安装说明
- Color---颜色对照表
- Python学习笔记(11):类的继承
- 短而实用的jQuery代码
- 面试题16:反转链表
- 富有魅力的git stash
- cocos2dx的发展的例子2048(加入动画版)
- Java串口通信详解
- Json_jackson_me
- BestCoder-Round#33
- Sql Server远程查询db 表中的数据,以本地
- 【Leetcode Algorithm】Add Binary
- unity3D 根据所在文件夹自动设置一些属性
- 初见WCF服务接口
- 在/dev下自动创建设备节点
- CentOS6下ssh简介及openssh的应用