How can HTML forms be automatically reset after a button click in PHP?
To automatically reset HTML forms after a button click in PHP, you can use JavaScript to reset the form fields. You can achieve this by adding an onclick event to the button that triggers a JavaScript function to reset the form.
<form id="myForm">
<input type="text" name="username">
<input type="password" name="password">
<button type="button" onclick="resetForm()">Reset Form</button>
</form>
<script>
function resetForm() {
document.getElementById("myForm").reset();
}
</script>
Keywords
Related Questions
- How can curl be utilized effectively in PHP to overcome SSL handshake failures and successfully establish secure connections?
- What are the best practices for handling data fetched from a database in PHP?
- What is the significance of using isset() in PHP when checking variables like in the provided code snippet?