我正在努力让这段代码发挥作用。
<form name="myform" onsubmit="alert('1');"> </form>
<a href="javascript: void(0);" onclick="document.myform.submit();">ok</a>
但是,当我单击“确定”时,什么也没有发生。我哪里搞错了?
最佳答案
The browser does not trigger the
onsubmit
event if you call thesubmit
method programmatically. Therefore, if the form is using the form validator script, call theonsubmit
method also to trigger the validation.
http://www.javascript-coder.com/javascript-form/javascript-form-submit.phtml (还有一个例子)
因此,您的表单已发布,但未触发 onsumbit
。
关于javascript - 通过单击链接将表单发布到对话框窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3968922/