Resetting Button Captions


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.

graphics/12fig05.gif



Inside Javascript
Inside JavaScript
ISBN: 0735712859
EAN: 2147483647
Year: 2005
Pages: 492
Authors: Steve Holzner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net