posts - 325,  comments - 25,  trackbacks - 0
          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
          <html xmlns="http://www.w3.org/1999/xhtml">
          <head>
          <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
          <title>無標題文檔</title>
          <script type="text/javascript">
          function addList(){
              
          var list = document.getElementById("list");
              
          for(var i = 1; i <= 5; i++){
                  
          var newOption = document.createElement("option");
                  newOption.setAttribute(
          "value", i);
                  newOption.appendChild(document.createTextNode(
          "測試數據" + i));
                  list.appendChild(newOption);
              }

          }


          function clearList(){
              
          var list = document.getElementById("list");
              
              
          for(var i = list.options.length; i >= 0; i--){
                  list.remove(i);
              }

              
          //注意:每刪除一個option其它option的index特性會自動重置,因此,按以下方法(即從上往下刪是清除不了的)
              //for(var i = 0; i< list.options.length; i++){
              //    list.remove(i);
              //}
          }

          </script>
          </head>
          <body>
          <select name="list" id="list">
          </select>
          <input type="button" onclick="addList()"  value="生成"/>
          <input type="button" onblur="clearList()" value="清空" />
          </body>
          </html>
          posted on 2008-08-26 14:46 長春語林科技 閱讀(274) 評論(0)  編輯  收藏 所屬分類: js
          <2008年8月>
          272829303112
          3456789
          10111213141516
          17181920212223
          24252627282930
          31123456

           

          長春語林科技歡迎您!

          常用鏈接

          留言簿(6)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          相冊

          收藏夾

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 车险| 香格里拉县| 平泉县| 武胜县| 沙雅县| 汤阴县| 绥芬河市| 年辖:市辖区| 德安县| 宝兴县| 张掖市| 星子县| 新建县| 昆明市| 贺州市| 泸溪县| 平阳县| 杨浦区| 曲阳县| 潼关县| 洱源县| 上饶市| 中超| 商丘市| 嘉善县| 云林县| 唐河县| 卢湾区| 兴义市| 陈巴尔虎旗| 台南县| 石狮市| 延川县| 肇源县| 苏尼特右旗| 邓州市| 比如县| 剑阁县| 舟曲县| 吉隆县| 东乌|