[JavaScript]讓CheckBox具有單選功能!

  • 14492
  • 0

摘要:[JavaScript]CheckBox具有單選功能...!


<html>
  <head><title>MARS TEST PAGE</title></head>

  <script>
  function chk(input)
  {
    for(var i=0;i<document.form1.c1.length;i++)
    {
      document.form1.c1[i].checked = false;
    }
    
    input.checked = true;
    return true;
  }
  </script>

  <body>
  <form name="form1">
    <input type="checkbox" name="c1" value="1" onclick="return chk(this);">A
    <input type="checkbox" name="c1" value="2" onclick="return chk(this);">B
    <input type="checkbox" name="c1" value="3" onclick="return chk(this);">C
  </form>
  </body>
</html>

 






Y2J's Life:http://kimenyeh.blogspot.tw/