Crazylife's avatar

How do anchor tag behave like a button submit and get the value in controller?

When the user click on the link below the form will submit, but my controller unable to get the value. Is there a way to fix this issue? Thanks.

<li role="presentation"><a role="menuitem" tabindex="-1" href="javascript:{}" onclick="this.form.submit()" name="action" value="auto">CSS</a></li>
0 likes
2 replies
mikefolsom's avatar

Only <input>, <option> and <button> elements will pass a value attribute in a form submission. Your best bet may be to use a <button> instead of an <a>, or put the value in a hidden form element (either would need to be inside the <form> tag):

<input type="hidden" name="action" value="auto">

Hard to give much more help without having any context for your code snippet.

1 like
tisuchi's avatar

Another idea can be, simply apply onclick jquery function on that link. Whenever anyone click on that, use Ajax to complete your work in PHP part.

1 like

Please or to participate in this conversation.