开发者

Post form into dialog window by clicking a link

开发者 https://www.devze.com 2023-01-20 15:43 出处:网络
I\'m trying to make this piece of code work. <form name=\"myform\" onsubmit=\"alert(\'1\');\"> </form>

I'm trying to make this piece of code work.

<form name="myform" onsubmit="alert('1');"> </form>
<a href="javascript: void(0);" onclick="doc开发者_如何学Cument.myform.submit();">ok</a>

However nothing happens when I click "ok". Where have I mistaken?


The browser does not trigger the onsubmit event if you call the submit method programmatically. Therefore, if the form is using the form validator script, call the onsubmit method also to trigger the validation.

http://www.javascript-coder.com/javascript-form/javascript-form-submit.phtml (there's also an example)

So, your form is posted but onsumbit is not triggered.

0

精彩评论

暂无评论...
验证码 换一张
取 消