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>無標(biāo)題文檔</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(
          "測試數(shù)據(jù)" + 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 長春語林科技 閱讀(272) 評論(0)  編輯  收藏 所屬分類: js

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


          網(wǎng)站導(dǎo)航:
          博客園   IT新聞   Chat2DB   C++博客   博問  
           
          <2008年8月>
          272829303112
          3456789
          10111213141516
          17181920212223
          24252627282930
          31123456

           

          長春語林科技?xì)g迎您!

          常用鏈接

          留言簿(6)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          相冊

          收藏夾

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 时尚| 兴山县| 探索| 镇宁| 江源县| 平遥县| 当雄县| 龙山县| 当阳市| 基隆市| 洱源县| 舞钢市| 太白县| 富宁县| 广州市| 汶上县| 桃源县| 绍兴市| 宁城县| 芜湖县| 潜山县| 杭州市| 前郭尔| 武鸣县| 滨州市| 太仆寺旗| 秦安县| 牟定县| 商水县| 五家渠市| 大渡口区| 哈尔滨市| 囊谦县| 阳信县| 盐津县| 东港市| 陈巴尔虎旗| 淮北市| 瑞昌市| 静安区| 双鸭山市|