You also can change button captions on-the-fly , using a button's value property. Here's an example where I change the caption of a button from Click Me! to Clicked! when the user clicks a button: (Listing 12-11.html on the web site)<HTML> <HEAD> <TITLE> Changing a Button's Caption </TITLE> <SCRIPT LANGUAGE="JavaScript"> <!-- function clicker() { document.form1.button1.value = "Clicked!" } // --> </SCRIPT> </HEAD> <BODY> <H1>Changing a Button's Caption</H1> <FORM NAME="form1"> <INPUT TYPE="BUTTON" NAME="button1" ONCLICK="clicker()" VALUE="Click Me!"> </FORM> </BODY> </HTML> You can see how this works in Figure 12.5; the code has changed the button's caption after I've clicked that button. Figure 12.5. Changing a button's caption.
|