JS下拉複選框的實現

來源:互聯網
上載者:User

標籤:style   blog   io   使用   java   ar   for   資料   2014   

<html>  <head>    <script src="jquery-1.7.2.min.js"></script>    <script src="jquery.easyui.min.js" ></script>    <link   rel="stylesheet" href="css/themes/metro/easyui.css" ></link>    <link   rel="stylesheet" href="css/themes/icon.css" ></link>  </head>  <body>  <form class="ui-forms p20" >   <input type="text" id="ysvalue" >                 <fieldset>                    <legend>反作弊資料匯出</legend>                    <div class="pt20">                    <table>                       <tr>                                                <td><label style="float: none">團單&nbsp;&nbsp;</label>                        <input type="text"  id="byJobName" name="byJobName" value="" size="20" ></td>                        <td><input type="checkbox"  id="byJobName" name="byJobName" value="" size="20" >只看黑名單團單</td>                       </tr>                       <tr>                        <td><label style="float: none">訂單ID</label>                        <input type="text"  id="byJobClass" name="byJobClass" value="" size="20" ></td>                        <td><label style="float: none">券碼ID</label>                        <input type="text"  id="byJobClass" name="byJobClass" value="" size="20" ></td>                       </tr>                       <tr>                        <td><label style="float: none">預算</label>                            <select id="cc" style="width:150px"></select><span style="white-space:pre"></span>                          <div id="sp"><span style="white-space:pre"></span>                        <input type="checkbox" id="ysqu" value="01" onclick="ysqx();"><span>全選</span><br/><span style="white-space:pre"></span>                        <input type="checkbox" id="lang" value="01"><span>Java</span><br/><span style="white-space:pre"></span>                        <input type="checkbox" id="lang" value="02"><span>C#</span><br/><span style="white-space:pre"></span>                        <input type="checkbox" id="lang" value="03"><span>Ruby</span><br/><span style="white-space:pre"></span>                        <input type="checkbox" id="lang" value="04"><span>Basic</span><br/><span style="white-space:pre"></span>                        <input type="checkbox" id="lang" value="05"><span>Fortran</span><span style="white-space:pre"></span>                          </div>                        </td>                        <td>&nbsp;</td>                         <td><button type="button" class="ui-button-red ui-button ui-widget ui-Status-default ui-corner-all ui-button-text-only"  onclick="search();" > &nbsp;查&nbsp; 詢&nbsp; </button>                             <button type="button" id="btnReset" name="btnReset" class="ui-button-red ui-button ui-widget ui-Status-default ui-corner-all ui-button-text-only" > &nbsp;重&nbsp; 置&nbsp; </button>                        </td>                        </tr></table>                    </div>                </fieldset>        </form>  <body></html><script type="text/javascript">// ready後把複選框列表載入到對應的select組裡$(function(){  $('#cc').combo({required:true,editable:false});  $('#sp').appendTo($('#cc').combo('panel'));  $('#sp input').click(function(){    var s = "";    if ($(this).attr("checked")){      // 當前複選框是選中狀態      s = $(this).next('span').text();      $('#cc').combo('setText', s);    } else {      // 當前複選框是非選中狀態,則找最近一個選中的狀態,如果沒有返回空值      for (var i=0;i<lang.length;i++ ){        if(lang[i].checked){          s = $(lang[i]).next('span').text();          break;        }      }      $('#cc').combo('setText', s);    }  });});// 點擊查詢按鈕function search(){  var value = "";  for (var i=0;i<lang.length;i++ ){     if(lang[i].checked){        value=value+lang[i].value + ",";     }  }  // 擷取所有選中的複選框的值,把值填充到一個text裡方便後面使用  ysvalue.value = value;}// 預算下拉複選框全選function ysqx(){   if (ysqu.checked) {      // 選中全選,讓所有複選框選中      for (var i=0;i<lang.length;i++ ){         lang[i].checked = true;       }   } else {      // 取消全選      for (var i=0;i<lang.length;i++ ){         lang[i].checked = false;       }   }}</script>

JS下拉複選框的實現

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.