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"...>
?
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.
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.
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.
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.
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>
<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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With