Hello World
          Java技術學習
          posts - 17,  comments - 7,  trackbacks - 0

          正好項目里要用到,自己寫了一下,記下來,以后可以用用

          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
          "<html>
          <head>
          <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
          <title>test checkbox</title>
          <script language="javascript">
          function checkall()
          {
          ? var objForm = document.ckform;
          ? var objLen = objForm.length;
          ? for (var elcount = 0; elcount < objLen; elcount++)
          ? {
          ??? if (objForm.elements[elcount].type == "checkbox")
          ??? {
          ????? objForm.elements[elcount].checked = true;
          ??? }
          ? }
          }
          function clearall()
          {
          ? var objForm = document.ckform;
          ? var objLen = objForm.length;
          ? for (var elcount = 0; elcount < objLen; elcount++)
          ? {
          ??? if (objForm.elements[elcount].type == "checkbox")
          ??? {
          ????? objForm.elements[elcount].checked = false;
          ??? }
          ? }
          }
          function checkop(opvalue){
          ? var objForm = document.ckform;
          ? var objLen = objForm.length;
          ? for (var elcount = 0; elcount < objLen; elcount++)
          ? {
          ??? if (objForm.elements[elcount].type == "checkbox")
          ??? {
          ??? ?if (objForm.elements[elcount].id.indexOf(opvalue)==0){
          ??????? objForm.elements[elcount].checked = true;
          ????? }
          ????? else{
          ????? ?objForm.elements[elcount].checked = false;
          ????? }
          ??? }
          ? }?
          }

          function checkresult(){
          ? var objForm = document.ckform;
          ? var objLen = objForm.length;
          ? var flag=true;
          ? var checkvalue="";
          ? for (var elcount = 0; elcount < objLen; elcount++)
          ? {
          ??? if (objForm.elements[elcount].type == "checkbox")
          ??? {
          ????? if(objForm.elements[elcount].checked ==true){
          ????? ?flag=false;
          ????? ?if (checkvalue==""){
          ????? ??checkvalue=objForm.elements[elcount].value;
          ????? ?}
          ????? ?else{
          ????? ??checkvalue=checkvalue+","+objForm.elements[elcount].value;
          ????? ?}
          ????? }
          ??? }
          ? }?
          ? if (flag==true){
          ? ?alert("至少選擇一個");
          ? }
          ? alert(checkvalue);
          }
          </script>
          </head>

          <body>
          <form name="ckform" method="post" action="">
          ? <table width="100%"? border="1">
          ??? <tr>
          ????? <td><input type="checkbox" id="1011" name="checkbox" value="1"></td>
          ????? <td><input type="checkbox" id="1022" name="checkbox" value="2"></td>
          ????? <td><input type="checkbox" id="1033" name="checkbox" value="3"></td>
          ??? </tr>
          ??? <tr>
          ????? <td><input type="checkbox" id="2011" name="checkbox" value="4"></td>
          ????? <td><input type="checkbox" id="2022" name="checkbox" value="5"></td>
          ????? <td><input type="checkbox" id="2033" name="checkbox" value="6"></td>
          ??? </tr>
          ??? <tr>
          ????? <td><input type="checkbox" id="3011" name="checkbox" value="7"></td>
          ????? <td><input type="checkbox" id="3022" name="checkbox" value="8"></td>
          ????? <td><input type="checkbox" id="3033" name="checkbox" value="9"></td>
          ??? </tr>
          ??? <tr>
          ????? <td><input type="button" name="bu1" id="bu1" value="全選" onClick="checkall();"><input type="button" name="bu2" id="bu2" value="全部不選" onClick="clearall();"></td>
          ????? <td><input type="button" name="Submit" value="選中一行" onClick="checkop('20');"></td>
          ????? <td><input type="button" name="Submit" value="提交" onClick="checkresult();"></td>
          ??? </tr>
          ? </table>
          </form>
          </body>
          </html>


          FeedBack:
          # aaaaaaaa[未登錄]
          2011-07-19 10:42 | aa
          aaaaaaaaaaaaa  回復  更多評論
            

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          <2025年5月>
          27282930123
          45678910
          11121314151617
          18192021222324
          25262728293031
          1234567

          常用鏈接

          留言簿(1)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 石狮市| 景德镇市| 遂昌县| 固始县| 江达县| 长丰县| 上杭县| 郎溪县| 克什克腾旗| 霍州市| 岗巴县| 蒲城县| 寿光市| 板桥市| 姚安县| 哈尔滨市| 东丰县| 日土县| 桦川县| 仁怀市| 长岛县| 余庆县| 博湖县| 涡阳县| 仙桃市| 磴口县| 弋阳县| 沂源县| 米脂县| 健康| 南皮县| 方城县| 启东市| 郓城县| 新昌县| 商都县| 绥阳县| 宿松县| 阿图什市| 长沙市| 双牌县|