Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a submit out of a <a href...>...</a> link?

I got an image with which links to another page using <a href="..."> <img ...> </a>.

How can I make it make a post like if it was a button <input type="submit"...>?

like image 921
fmsf Avatar asked Nov 08 '08 18:11

fmsf


People also ask

How do I submit a form to href?

You can use href=”#top” or href=”#” to link to the top of the current page. To use the anchor tag as submit button, we need the help of JavaScript. To submit the form, we use JavaScript . submit() function.

How do you make a submit button a link?

Link Submit Button Using Anchor Tags In HTML In HTML, linking submit buttons using the Anchor Tag is a simple and dependable approach. Write/Declare a Submit button between the Anchor tag's Starting and Closing tags. Give a Path where you wish to link your Submit Button by using the href property of the Anchor element.

Can a link have Type submit?

Definitely, there is no solution with pure HTML to submit a form with a link ( a ) tag. The standard HTML accepts only buttons or images.

How do you submit a form in HTML?

The Submit Button The <input type="submit"> defines a button for submitting the form data to a form-handler. The form-handler is typically a file on the server with a script for processing input data. The form-handler is specified in the form's action attribute.


2 Answers

More generic approatch using JQuery library closest() and submit() buttons. Here you do not have to specify whitch form you want to submit, submits the form it is in.

<a href="#" onclick="$(this).closest('form').submit()">Submit Link</a> 
like image 186
Paulius Zaliaduonis Avatar answered Sep 28 '22 05:09

Paulius Zaliaduonis


<input type="image" name="your_image_name" src="your_image_url.png" /> 

This will send the your_image_name.x and your_image_name.y values as it submits the form, which are the x and y coordinates of the position the user clicked the image.

like image 28
Paige Ruten Avatar answered Sep 28 '22 04:09

Paige Ruten