• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Using Forms

When you add HTML controls to a web page, they should be in a form, which you create with the <FORM> element. Forms are only HTML constructs. They have no visual representation by themselves (unless you use the <FIELDSET> element; see the discussion on that element at the end of this chapter). We’ve been using forms since Chapter 1, “Essential JavaScript,” as in this example where I’ve placed an HTML button control into a form; and when the user clicks it, JavaScript calls the alerter method to display an alert box.

(Listing 01-03.html on the web site):

<HTML> 
    <HEAD> 
        <TITLE> 
            Executing Scripts in Response to User Action 
        </TITLE> 
        <SCRIPT LANGUAGE="JavaScript"> 
            <!--
            function alerter()
					{
					window.alert("You clicked the button!")
					} 
            // --> 
        </SCRIPT> 
    </HEAD> 

    <BODY> 
        <H1>Executing Scripts in Response to User Action</H1> 
        <FORM> 
            <INPUT TYPE="BUTTON" ONCLICK="alerter()" VALUE="Click Me!"> 
        </FORM> 
    </BODY> 
</HTML> 


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint