现在的位置: 首页 > 综合 > 正文

需要在JS中修改form的action属性,但form里面有个控件也叫action,我的处理方法

2012年08月24日 ⁄ 综合 ⁄ 共 2929字 ⁄ 字号 评论关闭

最好不要使用默认的属性名称  
  不过用了程序也不会出错,  
  只是会出现意想不到的东西。  
   
  如:  
  <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  

抱歉!评论已关闭.