laoding
          本來我以為,隱身了別人就找不到我,沒有用的,像我這樣拉風的男人,無論走到哪里,都像在黑暗中的螢火蟲一樣,那樣的鮮明,那樣的出眾。我那憂郁的眼神,稀疏的胡茬,那微微隆起的將軍肚和親切的笑容......都深深吸引了眾人......
          posts - 0,  comments - 37,  trackbacks - 0
          上次遇到要將有數據的表單實現重置功能,在網上找了好久才找到一個,也不知道是那位仁兄的了,考慮到可能比較難找,這里貼出來供大家參考,也方便自己復習。

          下面是JS代碼:

             function clearForm() {  
                          
                          var formObj 
          = document.forms[0];   
                       var formEl 
          = formObj.elements;     
                       
          for (var i=0; i<formEl.length; i++
                           { 
                               var element 
          = formEl[i];         
                               
          if (element.type == 'submit') { continue; }        
                               
          if (element.type == 'reset') { continue; }        
                               
          if (element.type == 'button') { continue; }      
                               
          if (element.type == 'hidden') { continue; }   
                               
          if (element.type == 'text') { element.value = ''; }  
                               
          if (element.type == 'textarea') { element.value = ''; }         
                               
          if (element.type == 'checkbox') { element.checked = false; }         
                               
          if (element.type == 'radio') { element.checked = false; }         
                               
          if (element.type == 'select-multiple') { element.selectedIndex = -1; } 
                               
          if (element.type == 'select-one') { element.selectedIndex = -1; }     
                          } 
                  }

          接下來是form:

          <form method="post" action="">      
                  
          <input type="text" value="解決方案" size="30" /> <br />     
                      
          <textarea name="" rows="3" cols="30">textarea</textarea> <br /> 
                          a
          <input type="checkBox" name="a" value="a" />     
                          b
          <input type="checkBox" name="a" value="b" checked="checked" />     
                          c
          <input type="checkBox" name="a" value="c" checked="checked" />     
                          d
          <input type="checkBox" name="a" value="d" />     
                          e
          <input type="checkBox" name="a" value="e" /> <br />     
                          
          2<input type="radio" name="b" value="2" />     
                          
          3<input type="radio" name="b" value="3" checked="checked" /><br />      
                      test1:
          <select name="" multiple="multiple">         
                          
          <option value="11111111">11111111</option>         
                          
          <option value="22222222" selected="selected">22222222</option>         
                          
          <option value="33333333" selected="selected">33333333</option>         
                          
          <option value="44444444">44444444</option>         
                          
          <option value="55555555">55555555</option>    
                       
          </select>      
                       
          <br /><br />      
                      test2:
          <select name="">         
                          
          <option value="11">11</option>         
                          
          <option selected="selected">22</option>         
                          
          <option value="33">33</option>         
                          
          <option value="44">44</option>         
                          
          <option value="55">55</option>     
                      
          </select>      
                      
          <br /><br />      
                      
          <input type="submit" value="Submit" />     
                      
          <input type="reset" value="Reset" />     
                      
          <input type="button" value="Button" />      
                      
          <input type="button" value="Javascript Clear" onclick="clearForm()" />  
              
          </form>


          試試吧,讓我們一起來感謝那位仁兄!!
          posted on 2008-11-06 12:56 老丁 閱讀(903) 評論(0)  編輯  收藏 所屬分類: js相關
          本博客主為學習和復習之用,無關其他,想罵人的繞道
          Email:dkm123456@126.com
          大家一起交流進步
          QQ:283582761


          <2025年7月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          留言簿(4)

          我參與的團隊

          文章分類(50)

          文章檔案(48)

          相冊

          朋友

          搜索

          •  

          積分與排名

          • 積分 - 96931
          • 排名 - 597

          最新評論

          主站蜘蛛池模板: 新竹市| 呼图壁县| 柏乡县| 方城县| 阳春市| 闻喜县| 潢川县| 涞源县| 肇源县| 沅陵县| 墨竹工卡县| 扎鲁特旗| 茶陵县| 巴南区| 西安市| 稷山县| 启东市| 土默特左旗| 姜堰市| 阿拉善左旗| 莲花县| 德江县| 仪征市| 平南县| 安阳县| 时尚| 凤庆县| 鄂伦春自治旗| 青岛市| 青铜峡市| 剑阁县| 建昌县| 德阳市| 盘锦市| 兴义市| 墨竹工卡县| 嘉善县| 临清市| 鲁山县| 贡觉县| 定兴县|