<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>

解决方案 »

  1.   

    这个错误显而易见,你在form里的控件叫cancel_time 但在js处理的时候名字是endcancel_time
      

  2.   

    干嘛不用 radio ?!!
      

  3.   

    不用radio是因为lz喜欢方块,不要园圈(美观要求把)
      

  4.   

    干嘛不用 radio ?!!
      

  5.   

    L@_@K  <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 />
        <input type="button" name="Button" value="  更 新 " class="crystal" >
      </form>
      

  6.   

    不管需求了,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>用一下下牛刀!</h4>
        <span id="spaModifyList">
        <!-- 不要再放其他 type 的 input -->
        <input type="checkbox" id="chbOption1" /><label FOR="chbOption1">是否改截止时间</label>
        <input type="checkbox" id="chbOption2" /><label FOR="chbOption2">是否改截止日期时间</label>
        <input type="checkbox" id="chbOption3" /><label FOR="chbOption3">再多也不怕,哈</label>
        </span>
        <input type="button" name="Button" value="  更 新 " class="crystal" >
        <script type="text/javascript">
        <!--
    var oContainer = document.getElementById("spaModifyList");
    oContainer.selectedId = "";
    var oOptions = oContainer.getElementsByTagName("input");for (var i=0; i<oOptions.length; i++)
    {
        oOptions[i].onclick = function ()
        {
            if (oContainer.selectedId != "")
            {
                var selectedOption = document.getElementById(oContainer.selectedId);
                selectedOption.checked = false;
            }        oContainer.selectedId = this.id;
            this.checked = true;
        };
    }
        //-->
        </script>
      </form>
     </body>
    </html>
      

  7.   

    如果用radio,但是万一选了一个,又想不选呢?
      

  8.   

    厄~~还是脚本......<input type="radio" onclick="this.checked = !this.checked">111哎~
    具体问题,具体分析~
      

  9.   

    在radio上加个事件,双击取消选择onDblClick="this.checked=false"
      

  10.   

    如此简单
    <!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>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>只能选择一个check</title><script language="javascript" type="text/javascript"></script>
    </head><body>
    <form id="hf">
    <input id="c1" type="checkbox" onclick="this.checked==true?hf.c2.disabled=true:hf.c2.disabled=false;" /><input id="c2" type="checkbox" onclick="this.checked==true?hf.c1.disabled=true:hf.c1.disabled=false;" /></form>
    </body>
    </html>