通过js实现一个form两个提交动作失败

2013-02-04 21:36:57 +08:00
 tangyuan
通过chrome的developer tool监控被告知说:
Uncaught SyntaxError: Unexpected token new find:7
Uncaught SyntaxError: Unexpected token )

下面的代码都是正确的,难道是Python bottle的tpl模板文件无法陷入javascript吗?
js部分
<script type="text/javascript">
function new()
{
document._form.action="/new";
document._form.submit();
}

function update()
{
document._form.action="/update";
document._form.submit();
}
</script>

html部分
<form name="_form" method="POST" action="">
<input type="button" name="create_record" id="create_record" value="Create" onclick="new();" />
<input type="button" name="update_record" id="update_record" value="Update" onclick="update();" />
</form>
2979 次点击
所在节点    JavaScript
4 条回复
takwai
2013-02-04 21:40:52 +08:00
function new() 这个是关键字,改改函数名称。
tangyuan
2013-02-04 21:44:46 +08:00
@takwai 果然如此!感谢takwai...
utom
2013-02-04 21:48:18 +08:00
@takwai 同楼上~
DaniloSam
2013-02-05 13:40:59 +08:00
new.........

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/59769

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX