If you want to give your users a place to enter a simple string of text,
you can give them a textbox with the code that appears below. Just to make things
really fun, let's add a Submit button. Here's how it's done:
<form action="nextpage.html" method="get" name="myform">
<input type="text" value="my box" name="thebox" align="top"
maxlength="25" size="40"><br>
<input type="submit" value="Take a Look" align="middle">
</form>
And here's the form the above code will produce.
There you go. To get that textbox, you just put an <input> tag
inside the <form> tag. The type attribute, which I've set as text, is what
makes this form a textbox. I included a value, which populates the textbox with the words "my box" (the user can override this value by typing
over it). The size attribute indicates the width of the textbox on the
page, and the maxlength attribute limits the number of characters a user
can enter. Just try entering 26 characters in this textbox. I dare you.
If you look at the Submit button, you'll see that the code here is
pretty similar. When the type attribute equals submit,
the browser gives us a button. And the text in the value attribute serves as the button's caption.
If you want to give your users more space, simply use a textarea tag:
<form>
<textarea cols=25 rows=6>The default value goes here.</textarea>
</form>
It looks like this:
Now that we have the basic, basic form down, let's take a closer look at
that opening <form> tag.
next page»