zoukankan
html css js c++ java
Javascript判断多选框checkbox和单选钮是否选中
//
第几个没有选
<
input type
=
"
checkbox
"
name
=
"
checkbox1
"
checked
>
<
input type
=
"
checkbox
"
name
=
"
checkbox1
"
>
<
input type
=
"
checkbox
"
name
=
"
checkbox1
"
checked
>
<
input type
=
"
checkbox
"
name
=
"
checkbox1
"
>
<
input type
=
"
checkbox
"
name
=
"
checkbox1
"
>
<
script language
=
javascript
>
function
check(obj)
{
for
(i
=
0
;i
<
document.all(obj).length;i
++
)
{
if
(
!
document.all(obj)[i].checked)alert(
"
第
"
+
(i
+
1
)
+
"
个没有选择
"
)
}
}
</
script
>
<
input type
=
button onclick
=
"
check('checkbox1')
"
value
=
"
检测
"
>
//
一个也没有选
<
input type
=
"
checkbox
"
name
=
"
test
"
>
<
input type
=
"
checkbox
"
name
=
"
test
"
>
<
input type
=
"
checkbox
"
name
=
"
test
"
>
<
input type
=
"
checkbox
"
name
=
"
test
"
>
<
input type
=
"
checkbox
"
name
=
"
test
"
>
<
Script Language
=
"
JavaScript
"
>
function
check(obj)
{
for
(i
=
0
;i
<
document.all(obj).length;i
++
)
{
if
(document.all(obj)(i).checked)
{
return
;
}
}
window.alert('一个也没有选!');
}
</
Script
>
<
input type
=
button onclick
=
"
check('test');
"
value
=
"
检测
"
>
<
script language
=
"
javascript
"
>
function
checkme()
{
var
checkmemberid;
//
定义团员
var
checkcontentid;
//
定义文章
checkmemberid
=
false
;
checkcontentid
=
false
;
//
判断团员是否选中
if
(document.all.memberid.checked
==
true
)
//
只有一个单选钮的情况
{
checkmemberid
=
true
;
}
for
(i
=
0
;i
<
document.all.memberid.length;i
++
)
//
有一组单选钮的情况
{
if
(document.all.memberid(i).checked)
{
checkmemberid
=
true
;
}
}
//
判断文章是否选中
if
(document.all.contentid.checked
==
true
)
//
只有一个单选钮的情况
{
checkcontentid
=
true
;
}
for
(i
=
0
;i
<
document.all.contentid.length;i
++
)
//
有一组单选钮的情况
{
if
(document.all.contentid(i).checked)
{
checkcontentid
=
true
;
}
}
//
将结果返回
if
(checkmemberid
==
false
)
{ window.alert(
"
请选择团员!
"
);
return
false
;
}
else
if
(checkcontentid
==
false
)
{
window.alert(
"
请选择文章!
"
);
return
false
;
}
return
true
;
}
</
script
>
查看全文
相关阅读:
【Hadoop报错】The directory item limit is exceeded: limit=1048576 items=1048576
【Error】mysql的error.log中ranges: 268 max_threads: 4 split: 268 depth: 2是什么意思?
【Hadoop】Hadoop集群组件默认端口
【Python】用Python把从mysql统计的结果数据转成表格形式的图片并推送到钉钉群
微信小程序 服务端shiro用户验证,偶然会出现验证失败的问题。
微信小程序 数组复制 改变原数组 新数组也会自动变化
Controller 在加入aop 后,@Autowired注入值为null
gitblit仓库
mybatis plus 增加数据后 返回主键id
Shiro 访问 Swagger2报404 及 放行Swagger2
原文地址:https://www.cnblogs.com/ghd258/p/270758.html
最新文章
Spring 中TransactionalEventListener事务提交后操作
Android studio 编译时出现Process 'command ' finished with nonzero exit value 1
浏览器缓存及http缓存
简化代码示例
Python 垃圾回收机制
文件系统Ext4详解
Python 迭代器
详解nohup和& 区别
C++异常实现机制
linux 文件锁flock,lockf,fcntl
热门文章
Python 列表推导
Python字符编码详解
状态模式
Python 中的type和object详解
取消 antdesign modal(模态框) 右上角×的默认事件,改为自定义
Selenium 使用手册
Python核心编程
网络层总结(2)TCP/IP模型的网络层
常氏家谱
Navicat Premium 查看MySQL数据库中的所有表记录数,还可以按记录数排序
Copyright © 2011-2022 走看看