JavaScript: Text "submit" link?
I have the the following code and want to use a hyper link to submit my form.
<form name="form_signup" id="form_signup" method="post" action="/" enctype="multipart/form-data">
...
<input type="submit" value="Go to Step 2" name="completed" /> or <a onclick="javascript:this.form.submit();">Proceed without uploading</a></span>
</form>开发者_Python百科
However, my hyperlink submit doesn't work. It just keeps me on the same page.
Question: any idea why my link submit text doesn't work?
The this
in your "javascript:this.form.submit();"
refers to the <a>
tag, which has no form
property, resulting in a JavaScript error.
The smallest required change, but far from the most elegant, would be something like this:
<a href="javascript:document.getElementById('form_signup').submit();">...</a>
精彩评论