午夜国产狂喷潮在线观看|国产AⅤ精品一区二区久久|中文字幕AV中文字幕|国产看片高清在线

    用htc實(shí)現(xiàn)CHECKBOX控件
    來源:易賢網(wǎng) 閱讀:798 次 日期:2014-09-25 09:44:52
    溫馨提示:易賢網(wǎng)小編為您整理了“用htc實(shí)現(xiàn)CHECKBOX控件”,方便廣大網(wǎng)友查閱!

    代碼如下:

    /*

    描述: CHECKBOX控件

    版本: 1.1

    備注: CHECKBOX控件背后跟隨的文字

    是獲取CHECKBOX對(duì)象的htc_myLabel來顯示的

    更新添加indeter屬性,用來增加不確定的選擇

    */

    <public:component>

    <public:attach event="oncontentready" onevent="fnInit()" />

    <public:attach event="onpropertychange" onevent="fnPropertychange()" />

    <script language="Javascript">

    var checkBoxImg=window.document.createElement("IMG");

    ImageArray=[];

    ImageArray["checkbox_false"]="checkbox_false.gif";

    ImageArray["checkbox_false_down"]="checkbox_false_down.gif";

    ImageArray["checkbox_false_over"]="checkbox_false_over.gif";

    ImageArray["checkbox_true"]="checkbox_true.gif";

    ImageArray["checkbox_true_down"]="checkbox_true_down.gif";

    ImageArray["checkbox_true_over"]="checkbox_true_over.gif";

    ImageArray["checkbox_indeter"]="checkbox_indeter.gif";

    ImageArray["checkbox_indeter_down"]="checkbox_indeter_down.gif";

    ImageArray["checkbox_indeter_over"]="checkbox_indeter_over.gif";

    function preLoad(path,obj){

    for(i in obj){

    this[i]=new Image();

    this[i].src=path+obj[i];

    }

    return this;

    }

    preb=new preLoad("images/",ImageArray);

    function fnInit(){

    var o=element;

    if(o.type=="checkbox"){

    var _table=window.document.createElement("TABLE");

    _table.cellSpacing="0px";

    _table.cellPadding="0px";

    _table.border="0px";

    if(o.disabled){

    _table.style.filter="alpha(Opacity=50)";

    }

    else{

    _table.style.filter="";

    }

    _table.style.display="inline";

    var _tr=_table.insertRow();

    var _td=_tr.insertCell();

    if (o.checked){

    checkBoxImg.src=preb["checkbox_true"].src;

    }

    else{

    checkBoxImg.src=preb["checkbox_false"].src;

    }

    if(o.indeter=="true"){

    o.indeterminate="true";

    checkBoxImg.src=preb["checkbox_indeter"].src;

    }

    _td.appendChild(checkBoxImg);

    _td=_tr.insertCell();

    _td.style.verticalAlign="bottom";

    if(o.htc_myLabel){

    _td.innerHTML=" <label style='cursor: hand'>"+o.htc_myLabel+"</label>";

    }

    o.insertAdjacentElement("afterEnd",_table);

    o.style.display="none";

    _table.attachEvent("onmouseover",function(){Baction("over")});

    _table.attachEvent("onmouseout",function(){Baction("out")});

    _table.attachEvent("onmousedown",function(){Baction("down")});

    _table.attachEvent("onmouseup",function(){Baction("up")});

    _table.attachEvent("onclick",function(){fnClick()});

    }

    }

    function fnPropertychange(){

    var o=element;

    switch(event.propertyName.toString().toLowerCase()){

    case "checked":

    Baction("up");

    break;

    }

    }

    function fnClick(){

    var o=element;

    if(o.type=="checkbox"){

    if(o.disabled)return;

    if(o.checked){

    checkBoxImg.src=preb["checkbox_false"].src;

    }

    else{

    checkBoxImg.src=preb["checkbox_true"].src;

    }

    o.checked=!o.checked;

    }

    }

    function Baction(action){

    var o=element;

    if(o.type=="checkbox"){

    if(o.disabled)return;

    if(action=="up"||action=="over"){

    if(o.indeterminate){

    checkBoxImg.src=preb["checkbox_indeter_over"].src;

    }

    else if(o.checked){

    checkBoxImg.src=preb["checkbox_true_over"].src;

    }

    else{

    checkBoxImg.src=preb["checkbox_false_over"].src;

    }

    }

    if(action=="out"){

    if(o.indeterminate){

    checkBoxImg.src=preb["checkbox_indeter"].src;

    }

    else if(o.checked){

    checkBoxImg.src=preb["checkbox_true"].src;

    }

    else{

    checkBoxImg.src=preb["checkbox_false"].src;

    }

    }

    if(action=="down"){

    if(o.indeterminate){

    checkBoxImg.src=preb["checkbox_indeter_down"].src;

    }

    else if(o.checked){

    checkBoxImg.src=preb["checkbox_true_down"].src;

    }

    else{

    checkBoxImg.src=preb["checkbox_false_down"].src;

    }

    o.indeterminate=false;

    }

    }

    }

    </script>

    </public:component>

    測試?yán)?

    復(fù)制代碼 代碼如下:

    <html>

    <head>

    <title> 新文檔 </title>

    <meta name="Generator" content="EditPlus">

    <meta name="Author" content="FlashSoft">

    <meta name="Keywords" content="">

    <meta name="Description" content="FlashSoft">

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    <style type="Text/Css">

    input.checkbox{

    behavior:url("behaviors/checkbox.htc");cursor: hand;

    }

    </style>

    </head>

    <body>

    <input name="chk1" type="checkbox" class="checkbox" htc_myLabel="音樂" checked>

    <input name="chk1" type="checkbox" class="checkbox" htc_myLabel="體育" disabled>

    <input name="chk1" type="checkbox" class="checkbox" htc_myLabel="新聞">

    <input name="chk1" type="checkbox" class="checkbox" htc_myLabel="不確定屬性1" indeter="true" checked>

    <input name="chk1" type="checkbox" class="checkbox" htc_myLabel="不確定屬性2" indeter="true" disabled>

    <input name="chk1" type="checkbox" class="checkbox" htc_myLabel="不確定屬性3" indeter="true">

    </body>

    </html>

    更多信息請(qǐng)查看IT技術(shù)專欄

    更多信息請(qǐng)查看腳本欄目
    易賢網(wǎng)手機(jī)網(wǎng)站地址:用htc實(shí)現(xiàn)CHECKBOX控件
    由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請(qǐng)考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!

    2025國考·省考課程試聽報(bào)名

    • 報(bào)班類型
    • 姓名
    • 手機(jī)號(hào)
    • 驗(yàn)證碼
    關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺(tái) | 手機(jī)站點(diǎn) | 投訴建議
    工業(yè)和信息化部備案號(hào):滇ICP備2023014141號(hào)-1 云南省教育廳備案號(hào):云教ICP備0901021 滇公網(wǎng)安備53010202001879號(hào) 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號(hào)
    云南網(wǎng)警備案專用圖標(biāo)
    聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號(hào):hfpxwx
    咨詢QQ:1093837350(9:00—18:00)版權(quán)所有:易賢網(wǎng)
    云南網(wǎng)警報(bào)警專用圖標(biāo)