html - Make link submit identically to default button behavior -


Sorry if it seems redundant, I have read through a few posts and can not figure out how to be done. I need an element that behaves like a button, but I thought instead to use a CSS class object. I find out how to do this by creating href = "#" and adding Javascript commands I

  & lt; P & gt; & Lt; Input name = "test" type = "button" value = "click" /> & Lt; / P & gt;   

However, due to server side software I am using I need to submit my form to duplicate the behavior of the button exactly.

I have been guessed:

  & lt; P & gt; & Lt; One square = "button" href = "#" onclick = "submit ()" & gt; Click & lt; / A & gt; & Lt; / P & gt;   

Thank you for your help!

You have the form in the context of the element, and then submit:

  & lt; P & gt; & Lt; A class = "button" href = "#" onclick = "document.getElementById ('myFormId') presented ()" & gt; Click & lt; / A & gt; & Lt; / P & gt;   

However, you should not use inline event delegation:

HTML:

  & lt; P & gt; & Lt; One class = "button" href = "#" id = "submit-anchor" & gt; Click & lt; / A & gt; & Lt; / P & gt;   

JS:

  document.getElementById ("submit-anchor"). addEventListener ("click", function () {document.getElementById ('myFormId'). Submit ();});    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -