Tao

          Tao obeys its own inherent Nature

          Using Javascript to access/change control's property

          Set readonly for input text

          document.getElementById("ctrl_id").readOnly  = true; //pay attention to the readOnly, it's case sensitive.

           

          Set option to unable to select for select control:

           

          <option value="Genre" disabled="disabled">Genre</option>

           

          Set select control to disabled (it has no readonly property):

           

          <select disabled="disabled"></select>

           

          Add a new option to a select control, it works under firefox 2.x and IE 5.x:

          function addOption(select_ctrl, option_value, option_text){
          var ctrl = document.getElementById(selectctl);

          if(ctrl == null)
          return;

          var doc = ctrl.ownerDocument;
          if (!doc)
          doc = ctrl.document;

          var opt = doc.createElement('OPTION');
          opt.value = option_value;
          opt.text = option_text;

          ctrl.options.add(opt, ctrl.options.length);
          }

           

          Delete an option from select control:

          selectctl.options[selectctl.selectedIndex] = null;

          Delete all options from select control:

          selectctrl.options.length = 0;

          Change the css for an object:

          document.getElementById("ctrl_id").className="SHOWN";

           

          posted on 2007-08-30 14:31 wade 閱讀(263) 評論(0)  編輯  收藏 所屬分類: Javascript


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


          網(wǎng)站導(dǎo)航:
           

          導(dǎo)航

          <2007年8月>
          2930311234
          567891011
          12131415161718
          19202122232425
          2627282930311
          2345678

          統(tǒng)計

          常用鏈接

          留言簿(7)

          隨筆分類

          隨筆檔案

          相冊

          Photo

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 连江县| 英吉沙县| 榆中县| 榆树市| 大关县| 嘉定区| 缙云县| 江达县| 衡南县| 弥勒县| 彰化市| 华宁县| 大厂| 香格里拉县| 南郑县| 江川县| 肇州县| 法库县| 渝中区| 汝阳县| 和硕县| 灌云县| 曲靖市| 汪清县| 嘉鱼县| 澎湖县| 库伦旗| 武平县| 湖北省| 盐池县| 元朗区| 东丰县| 尚志市| 青浦区| 凤城市| 通州区| 昭通市| 咸宁市| 呼和浩特市| 景德镇市| 乌拉特中旗|