Home > Article > Web Front-end > How Can I Submit Forms Using Hyperlinks Instead of Buttons?
Submit Forms with Normal Links
In certain scenarios, it may be desirable to submit forms using hyperlinks rather than traditional submit buttons. This article explores two methods to achieve this functionality:
Method 1: Styling a Button as a Link
This approach involves creating a standard HTML button and enhancing its appearance through CSS to resemble a link:
<button type="submit" class="link-button">Save</button> .link-button { border: none; padding: 0; text-decoration: underline; color: blue; cursor: pointer; }
Method 2: Utilizing a Link with JavaScript
Alternatively, a hyperlink can be used directly by incorporating JavaScript to trigger the form submission:
<a href="#" onclick="this.closest('form').submit();return false;">Save</a>
The above is the detailed content of How Can I Submit Forms Using Hyperlinks Instead of Buttons?. For more information, please follow other related articles on the PHP Chinese website!