Sams Teach Yourself HTML, CSS & JavaScript Web Publishing in One Hour a Day

(singke) #1
ptg16476052

Using the <form> Tag 319

12


To complete the exercise, let’s test the form to see whether it produces the data we
expect. Because you don’t have the script “form-processing-script” available on your
hard drive, you should modify your

tag to send the data to the page with a get
request:



Then when you submit your form, here’s what the data that’s sent to the server looks
like:


username=somename&password=somepassword


This data will appear at the end of the URL in your browser window as in Figure 12.3.


FIGURE 12.2
A simple form.


FIGURE 12.3
The URL field after
submitting a form


Most forms won’t work if they are not on a web server. And if the
URL in the action attribute does not exist, the form won’t work
when you submit it.

CAUTION

It’s pretty measly, but you can see that the names assigned to each field are tied to the
values entered in those fields. You can then use a program to use this data to process the
user’s request.


Using the Tag


To accept input from a user, you must wrap all of your input fields inside a tag.
The purpose of the tag is to indicate where and how the user’s input should be
sent. First, let’s look at how the tag affects page layout. Forms are block-level



Free download pdf