当前位置: 代码迷 >> JavaScript >> 在JS中批改form的action属性
  详细解决方案

在JS中批改form的action属性

热度:126   发布时间:2012-11-01 11:11:33.0
在JS中修改form的action属性
引用
转载于:http://topic.csdn.net/t/20020801/13/916158.html


如:
<form   action="test12.asp"   method="get"   onsubmit="_submit()"   name='frm'>   
    
  <INPUT   type="text"   id=text1   name=action>   
  <INPUT   type="submit"   value="Submit"   id=submit1   name=submit1>   
  </form>   
    
  <script>   
  function   _submit(){   
  frm.action.value="ddddddddd"   
  }   
  </script>   


这段代码执行的结果将会是input名为action的值,而不是form的action属性值。
此情况下如仍要使用,可使用attributes
即:  
引用
frm.attributes[83].value="test2.asp"  


至于83如何得到,可用以下程序获取:  
  for(i=0;i<frm.attributes.length;i++){   
  document.write(frm.attributes[i].name+"-------Index:"+i+"<br>");   
  } 
 

结果:
  • language-------Index:0  
  •   dataFld-------Index:1  
  •   onmouseup-------Index:2  
  •   class-------Index:3  
  •   oncontextmenu-------Index:4  
  •   onrowexit-------Index:5  
  •   onbeforepaste-------Index:6  
  •   onactivate-------Index:7  
  •   lang-------Index:8  
  •   onmousemove-------Index:9  
  •   onmove-------Index:10  
  •   onselectstart-------Index:11  
  •   oncontrolselect-------Index:12  
  •   onkeypress-------Index:13  
  •   oncut-------Index:14  
  •   onrowenter-------Index:15  
  •   onmousedown-------Index:16  
  •   onpaste-------Index:17  
  •   id-------Index:18  
  •   onreadystatechange-------Index:19  
  •   onbeforedeactivate-------Index:20  
  •   hideFocus-------Index:21  
  •   dir-------Index:22  
  •   onkeydown-------Index:23  
  •   onlosecapture-------Index:24  
  •   ondrag-------Index:25  
  •   ondragstart-------Index:26  
  •   oncellchange-------Index:27  
  •   onfilterchange-------Index:28  
  •   onrowsinserted-------Index:29  
  •   ondatasetcomplete-------Index:30  
  •   onmousewheel-------Index:31  
  •   ondragenter-------Index:32  
  •   onblur-------Index:33  
  •   onresizeend-------Index:34  
  •   onerrorupdate-------Index:35  
  •   onbeforecopy-------Index:36  
  •   ondblclick-------Index:37  
  •   onkeyup-------Index:38  
  •   onresizestart-------Index:39  
  •   onmouseover-------Index:40  
  •   onmouseleave-------Index:41  
  •   onmoveend-------Index:42  
  •   title-------Index:43  
  •   onresize-------Index:44  
  •   contentEditable-------Index:45  
  •   dataFormatAs-------Index:46  
  •   ondrop-------Index:47  
  •   onpage-------Index:48  
  •   onrowsdelete-------Index:49  
  •   style-------Index:50  
  •   onfocusout-------Index:51  
  •   ondatasetchanged-------Index:52  
  •   ondeactivate-------Index:53  
  •   onpropertychange-------Index:54  
  •   ondragover-------Index:55  
  •   onhelp-------Index:56  
  •   ondragend-------Index:57  
  •   onbeforeeditfocus-------Index:58  
  •   disabled-------Index:59  
  •   onfocus-------Index:60  
  •   accessKey-------Index:61  
  •   onscroll-------Index:62  
  •   onbeforeactivate-------Index:63  
  •   onbeforecut-------Index:64  
  •   dataSrc-------Index:65  
  •   onclick-------Index:66  
  •   oncopy-------Index:67  
  •   onfocusin-------Index:68  
  •   tabIndex-------Index:69  
  •   onbeforeupdate-------Index:70  
  •   ondataavailable-------Index:71  
  •   onmovestart-------Index:72  
  •   onmouseout-------Index:73  
  •   onmouseenter-------Index:74  
  •   onlayoutcomplete-------Index:75  
  •   implementation-------Index:76  
  •   onafterupdate-------Index:77  
  •   ondragleave-------Index:78  
  •   name-------Index:79  
  •   onreset-------Index:80  
  •   accept-charset-------Index:81  
  •   onsubmit-------Index:82  
  •   action-------Index:83  
  •   method-------Index:84  
  •   target-------Index:85  
  •   encType-------Index:86
 
  相关解决方案