<script>
function checkradio(){
var a=document.getElementsByTagName("input");
var choiceornot = false
for(i=0;i<a.length;i++){
//alert(a[i].type);
if(a[i].type=="radio"){
if(a[i].checked){
choiceornot = true
continue;
}
}
}
if(!choiceornot){
alert("no")
}
}
</script>
<input type="radio" name="bb" value="win">
<input type="radio" name="bb" value="tie">
<input type="radio" name="bb" value="lost"><br>
<input type="radio" name="aa" value="win">
<input type="radio" name="aa" value="tie">
<input type="radio" name="aa" value="lost"><br>
<input type="button" onclick="checkradio()">
function checkradio(){
var a=document.getElementsByTagName("input");
var choiceornot = false
for(i=0;i<a.length;i++){
//alert(a[i].type);
if(a[i].type=="radio"){
if(a[i].checked){
choiceornot = true
continue;
}
}
}
if(!choiceornot){
alert("no")
}
}
</script>
<input type="radio" name="bb" value="win">
<input type="radio" name="bb" value="tie">
<input type="radio" name="bb" value="lost"><br>
<input type="radio" name="aa" value="win">
<input type="radio" name="aa" value="tie">
<input type="radio" name="aa" value="lost"><br>
<input type="button" onclick="checkradio()">
解决方案 »
- 无数据报错,有数据正常
- ***简单:如何限制输入框输入的内容必须是整数***
- 怎样在jscript中获得InternetExplorer对象
- 在js中如何比较两个时间字符串的大小
- 在网页中使用自定义的鼠标光标
- 用javascript实现删除本地硬盘上的文件。
- 怎样让iframe调用父页面的javascript函数?
- javascript中用windows.open后怎样才能使session不改变。---着急等用,谢谢了!!
- 我没有学过JavaScript,它就是Java语言吗?它能做什么?我以前是学DELPHI,现在想做一个网站,要有数据库,希望各位高手提提意见。
- 触摸拖拽缩放大小 h5
- 谁能给你一个创建无极菜单的例子,100分敬候!
- 字符串减
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD><BODY>
<INPUT TYPE="radio" NAME="rad1"><br>
<INPUT TYPE="radio" NAME="rad2"><br>
<INPUT TYPE="radio" NAME="rad3"><br>
<INPUT TYPE="radio" NAME="rad4"><br>
<INPUT TYPE="radio" NAME="rad5"><br>
<INPUT TYPE="button" NAME="btn" onclick="clk()">
</BODY>
</HTML><SCRIPT LANGUAGE="JavaScript">
<!--
function clk() {
var bo_all_no = true;
var bo_all_yes = true;
var ar_radio = document.getElementsByTagName("INPUT");
for( var i=0; i<ar_radio.length; i++ ) {
if( ar_radio[i].type == "radio" ) {
if( ar_radio[i].checked == true ) {
bo_all_no = false;
} else {
bo_all_yes = false;
}
}
}
if( bo_all_no == true ) {
alert("全部没有选中");
}
if( bo_all_yes == true ) {
alert("全部选中");
}
}
//-->
</SCRIPT>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head><body>
<script>
function checkradio(){
var a=document.getElementsByTagName("input");
var aa=0;
var bb=0;
for(i=0;i<a.length;i++){
if(a[i].type=="radio" && a[i].name=="bb")
{
if(a[i].checked && bb!=1)
{
bb=1;
}
}
if(a[i].type=="radio" && a[i].name=="aa")
{
if(a[i].checked && aa!=1)
{
aa=1;
}
}
}
if(aa==1 && bb==1)
alert("yes");
else
alert("no");
}
</script>
<input type="radio" name="bb" value="win">
<input type="radio" name="bb" value="tie">
<input type="radio" name="bb" value="lost"><br>
<input type="radio" name="aa" value="win">
<input type="radio" name="aa" value="tie">
<input type="radio" name="aa" value="lost"><br>
<input type="button" onclick="checkradio()">
</body>
</html>