Working with Generic Buttons

Generic buttons (see Figure 68.1) are clickable, but they don't do anything when the visitor clicks them, unlike submit and reset buttons. You must specifically program these buttons to do what you want them to do, which is usually to launch a JavaScript function. The button's input tag takes the onClick event, where you put the name of the function that you want to launch.

Listing 68.1. View Source for Figure 68.1.
<form>
  <input type="button" name="totalButton"  value="Calculate Total" onClick="doTotal();">
</form>
Figure 68.1. A generic button is clickable, but it doesn't do anything until you add an onClick event to its tag.

The name attribute of the button's input tag identifies the button, ...

Get Web Design Garage now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.