Using Buttons
Explore how to effectively use various HTML buttons within web forms, including submit, reset, and image input types. Understand how to handle button events with JavaScript functions and override form actions with the formaction attribute. This lesson prepares you to create interactive and flexible form controls.
In the previous form examples, you only used one kind of button, the submit button, which was represented by an <input> tag with type set to “submit”. You have other options to use buttons in your forms, here you will review them.
In the Exercise folder, you’ll find a project that includes a number of HTML files.
When you work with forms, you do not have to send the form back to the server, you may run a JavaScript function to respond to the event when the user submits the form.
The Listing below demonstrates this; it shows that every time the user clicks the submit button, the changeBy() JavaScript method is called with “1” passed as the function argument.