控制form中两个check不能同时选择
<form name= "form1 " method= "post " action= "aaaa.asp ">
<input name= "cancel_time " type= "checkbox " id= "cancel_time ">
是否改截止时间
<input name= "cancel_time2 " type= "checkbox " id= "cancel_time2 ">
是否改截止日期时间
<input type= "button " name= "Button " value= " 更 新 " class= "crystal " onClick= "javascript:submit_confirm(); ">
</form>
function submit_confirm() {
if(form1.endcancal_time.checked==true &&form1.endcancal_time2.checked==true){
alert( "“是否改截止日期”和“是否改截止日期时间”不能同时选择! ");
return false;
}
else
{
document.form1.submit();
}
}
endcancal_time和endcancal_time2可以同时不选,可以任选一个,但不能同时选,我用上面的函数控制,没起到作用,请大家指点一下
------解决方案-------------------- <form action= " " method= "post " name= "form1 ">
<input id= "cancel_time " name= "cancel_time " type= "checkbox ">
是否改截止时间
<input id= "cancel_time2 " name= "cancel_time2 " type= "checkbox ">
是否改截止日期时间
<input class= "crystal " name= "Button " onclick= "javascript:submit_confirm(); " type= "button "
value= " 更 新 ">
</form>
<script>
function submit_confirm() {
if(document.getElementById( 'cancel_time ').checked == true && document.getElementById( 'cancel_time2 ').checked == true){
alert( "“是否改截止日期”和“是否改截止日期时间”不能同时选择! ");
return false;
}
else
{
document.form1.submit();
}
}
</script>
------解决方案--------------------不管需求了,LZ 自己看着办,写个通用的
L@_@K
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<title> selecte single checkbox </title>
<meta name= "generator " content= "editplus " />
<meta name= "author " content= "yixianggao " />
<meta name= "keywords " content= "javascript " />
<meta name= "description " content= "for csdn " />
</head>
<body>
<form name= "form1 " method= "post " action= "aaaa.asp ">
<h4> 根本无需脚本!杀鸡焉用牛刀! </h4>
<input type= "radio " name= "modifyList " id= "radOption1 "> <label FOR= "radOption1 "> 是否改截止时间 </label>
<input type= "radio " name= "modifyList " id= "radOption2 "> <label FOR= "radOption2 "> 是否改截止日期时间 </label> <br /> <br />
<h4> 用一下下牛刀!