佳木斯湛栽影视文化发展公司

主頁(yè) > 知識(shí)庫(kù) > 用htc實(shí)現(xiàn)CHECKBOX控件

用htc實(shí)現(xiàn)CHECKBOX控件

熱門標(biāo)簽:網(wǎng)站文章發(fā)布 服務(wù)器配置 美圖手機(jī) 檢查注冊(cè)表項(xiàng) 呼叫中心市場(chǎng)需求 鐵路電話系統(tǒng) 銀行業(yè)務(wù) 智能手機(jī)
復(fù)制代碼 代碼如下:

/*
描述:        CHECKBOX控件
版本:        1.1
備注:        CHECKBOX控件背后跟隨的文字
            是獲取CHECKBOX對(duì)象的htc_myLabel來(lái)顯示的
            更新添加indeter屬性,用來(lái)增加不確定的選擇
*/
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="nbsplabel 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>

測(cè)試?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="音樂(lè)" 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>

下載此文件
您可能感興趣的文章:
  • Asp.net Mvc 身份驗(yàn)證、異常處理、權(quán)限驗(yàn)證(攔截器)實(shí)現(xiàn)代碼
  • asp.net中3種驗(yàn)證碼示例(實(shí)現(xiàn)代碼)(數(shù)字,數(shù)字字母混和,漢字)
  • 驗(yàn)證用戶必選CheckBox控件與自定義驗(yàn)證javascript代碼

標(biāo)簽:長(zhǎng)治 紅河 河南 上海 樂(lè)山 滄州 沈陽(yáng) 新疆

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《用htc實(shí)現(xiàn)CHECKBOX控件》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266
    兰坪| 霸州市| 邵阳县| 措勤县| 南陵县| 苗栗市| 迭部县| 年辖:市辖区| 福贡县| 浦县| 安泽县| 昔阳县| 双峰县| 博客| 武平县| 武鸣县| 房山区| 卢氏县| 汉阴县| 广元市| 台湾省| 衡水市| 辽阳市| 普兰店市| 巫溪县| 佛冈县| 建瓯市| 肇州县| 黔西| 雷山县| 梁山县| 射阳县| 临猗县| 加查县| 远安县| 新乐市| 南昌县| 宁强县| 清河县| 襄垣县| 托克托县|