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 閱讀(262) 評論(0)  編輯  收藏 所屬分類: Javascript


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


          網站導航:
           

          導航

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

          統計

          常用鏈接

          留言簿(7)

          隨筆分類

          隨筆檔案

          相冊

          Photo

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 左权县| 尼玛县| 忻州市| 潍坊市| 宽甸| 贵港市| 习水县| 精河县| 栾城县| 岑巩县| 郓城县| 望江县| 成安县| 上思县| 永川市| 安义县| 东方市| 绍兴县| 凌云县| 泸水县| 浮山县| 广昌县| 吴川市| 汉沽区| 山西省| 锦州市| 林西县| 高淳县| 集安市| 闸北区| 桦南县| 桦川县| 栾城县| 白朗县| 施秉县| 蓬莱市| 建昌县| 子长县| 鱼台县| 通河县| 丹巴县|