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

AYellow 2002-08-01 01:49:41
如题
...全文
432 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
ssm1226 2002-08-01
  • 打赏
  • 举报
回复
如有问题与俺联系:
ssm1226@yahoo.com.cn
msn:ssm1226@msn.com
ssm1226 2002-08-01
  • 打赏
  • 举报
回复
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

ssm1226 2002-08-01
  • 打赏
  • 举报
回复
最好不要使用默认的属性名称
不过用了程序也不会出错,
只是会出现意想不到的东西。

如:
<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>");
}
qiushuiwuhen 2002-08-01
  • 打赏
  • 举报
回复
form1["action"]
or
form1.all("action")
etc.

<script>
function test()
{
form1.all("action").value="next.jsp";
}
</script>
<form name=form1>
<input name=action value=qiushuiwuhen>
<input type=button onclick="test()">
</form>
meizz 2002-08-01
  • 打赏
  • 举报
回复
确实是不可以将表单里的元素命名为action的,否则这种情况就会出错。
leng_cn 2002-08-01
  • 打赏
  • 举报
回复
不能这样的,表单元素的名字不可以和表
单的属性名相同的
seabell 2002-08-01
  • 打赏
  • 举报
回复
表单元素的名字不可和系统的属性名等相同
<script>
function test()
{
form1.action="next.jsp";
form1.submit();
}
</script>
<form name=form1>
<input name=action1>
<input type=button onclick="test()">
</form>

87,904

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧