04.06.2013 Views

Head First HTML with CSS

Head First HTML with CSS

Head First HTML with CSS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Adding the form element<br />

Once you know the URL of the Web application that will process your form, all you<br />

need to do is plug it into the action attribute of your element, like this<br />

(follow along and type the changes into your X<strong>HTML</strong>):<br />

xhtml forms<br />

<br />

<br />

<br />

<br />

The Starbuzz Bean Machine<br />

<br />

<br />

The Starbuzz Bean Machine<br />

Fill out the form below and click submit to order<br />

<br />

<br />

<br />

<br />

Here’s the<br />

form element. The action attribute contains the<br />

Go ahead and add the<br />

form closing tag too.<br />

URL of the Web application.<br />

So far so good, but an empty element isn’t going to get you very far.<br />

Looking back at the sketch of the form, there’s a lot there to add, but we’re going<br />

to start simple and get the “Ship to:” part of the form done first, which consists of<br />

a bunch of text inputs. You already know a little about text inputs, but let’s take a<br />

closer look. Here’s what the text inputs for the Starbuzz form look like:<br />

We use the <br />

element for a few<br />

different controls.<br />

The type attribute<br />

determines what kind<br />

of control it is.<br />

<br />

<br />

<br />

<br />

<br />

Here the type is “text” because this<br />

is going to be a text input control.<br />

And remember we’re using the<br />

“POST” method to deliver<br />

the form data to the server.<br />

More on this later.<br />

We’ve got one<br />

text input for<br />

each input area in<br />

the form: Name,<br />

Address, City,<br />

State, and Zip.<br />

The name attribute acts as an identifier for the<br />

data the user types in. Notice how each one is set to<br />

a different value. Let’s see how this works...<br />

you are here 605

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!