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-04-08 folder within the source code download of the chapter, 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.

Listing 4-2 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.

Get hands-on with 1200+ tech skills courses.