Browse Sections

Intermediate HTML

Lesson 4: Using forms to get visitor feedback

Entering text

Now, if you need your visitor to enter something that can't be a choice, like his or her street address, for example, you need a different type of input element. That's why the powers that be invented the text element.

It looks like this:

My best quality is:

Here's the syntax:

My best quality is:
<input type="text" name="best" size="40" maxlength="200" />

Looks familiar, doesn't it? It's the same syntax as the other <input> elements you've been using. You can even use the "value" attribute and specify an initial value if you want. What's new is that, because this is free form input, you have a size attribute to specify how long it will appear on the page (in characters), and a maxlength attribute to specify the maximum number of characters you want users to be able to input. Why they don't call it "size" and "maxsize" or "length and "maxlength" I don't know, but it's in your book on page 272, so if you forget the syntax, you can always look it up.

The only problem with the text type of input field is that it will give your visitor only one line for input. For entering a whole paragraph, as when you are asking a customer to describe her individual needs, soliciting comments or taking complaints, you need a different form element: <textarea> .

Sadly, the syntax for textareas is completely different. I imagine the people designing that form element weren't speaking to the people designing the "input" elements. Maybe they had an argument that day. I don't know.

Here's the syntax:

<textarea name="lotsatext" rows="6" cols="60">
Default text goes here, not in a "value" attribute.
</textarea>

which will look like:

So try adding a textarea and a text element or two to your form. Go ahead. You'll like it. If you need help, don't forget that the forum is your friend.

Print this Page Print this page


Previous Page  1  2  3  4  5   Next Page

Lessons

Lesson 1: Cascading Style Sheets
Lesson 2: Intermediate Page Design
Lesson 3: How to add programming to your pages without being a programmer
Lesson 4: Using forms to get visitor feedback
• Entering text