computer, hardware e software, Learn about the PC, what you'll need to build a PC and discover if building a PC will be right for you
personal, computer, information,Build Your Own PC,pc hardware,pc store,new pc,computer hardware,pc software,pc online,computer information,online pc,hardware pc,information computer,about computer hardware,information on computer,computer hardware system,computer system hardware
Time’s passing us by, my friends. The further we get through the lesson, the more you’ll realise we’re reaching the limits.
What ? You lied to us ?! XHTML and CSS have limits ? We can’t do everything with them ?!
On a serious note, yes XHTML and CSS do have limits. You can already make a good site with what I’ve taught you, but imagine that one day you want to make an awesome site ? We’re getting there. What I’m going to teach you will still be XHTML, but you will realise that we’ve reached the limits of the language.
But maybe that’s a good sign. It might mean that you’ve become good and that XHTML isn’t enough anymore
What will we talk about in this chapter ? We’re going to talk about forms. The idea is simple : you’ve created a site, and for example, you’d like it if you’re visitors could leave their thoughts by ticking boxes, inserting their comments, their suggestions …
Welcome to the wonderful world of forms, the world where check boxes, buttons and scrolling lists live in perfect harmony (or almost )
When you want to insert a form into your XHTML page, you need to use the
tags. It’s the main tag of a form; it allows is to indicate the beginning and the end of the form.
Code : HTML
Text before the form
Text after the form
So that is the basic structure. Now pay attention, because what I’m going to say is not evident seeing as we’re at the limits of XHTML.
A form is created to be sent. We’ll take an example to make things clear. Let’s suppose that a visitor leaves a comment in your form, for example Yeeaahhhh, this site is great ! This message needs to be sent so that you can receive it (makes sense doesn’t it ?), and so that you can find out what the visitor thinks of your site.
Well, that’s where the problem is, or more precisely :
Problem 1 : how do you send the text left by the visitor ?
Problem 2 : once the data has been sent, how do you process it ? Do you want to receive it automatically be email, or do you want it to be saved somewhere, then show it on a page for everyone to see ? That’s the same as a guest book if you were following properly
There are 2 attributes for the
Text after the form
For the moment, we don’t know what happens in process.php : all that I ask is that you trust me, and imagine that this page does exist, and works. In the lessons on PHP we’ll see how this page analyses the data, but for the moment that isn’t our priority.
Our priority, here, is to see how we insert text areas, buttons and check boxes into our web page using XHTML. That’s what we’re going to learn now
We’re going to see the tags that allow us to insert text areas into a form. To start, you need to know that there are 2 types of text areas :
single line text areas : as its name says, we can only write one line of text inside it :p. It’s for inserting short text, for example : insert your username.multi line text areas : this allows us to insert a more important amount of text on several lines, for example : insert your address.
You don’t know what a text area is ? That’s alright, I’ve got a picture of one :
To insert a single text area, we use the tag. We’ll use this tag a few times in this chapter. Each time the attributes will change.
To insert a single line text area, we need to write :
But that’s not it ! We’re missing an attribute that will be very important ; the name of the text area. In effect, that will allow us later (in PHP) to recognise which text is the username, which text is the password etc… Therefore we need to give a name to the text area with the attribute name. Here, we will suppose that we want the visitor’s username :
Now we’ll test that :
Code : HTML
Don’t forget to surround the text area with or your web page won’t be valid.
It’s all very well having a text area, but if a visitor see’s it, they won’t know what to put in it. We have to tell them that the box is for their username. To indicate what a text area is for we use the
Code : HTML
But that’s not enough. We need to link the label to the text area. To do this we need to give the text area a name, not with the attribute name, but with the attribute id (which we can use on all tags).
A name and an id on a text area ? Won’t they both do the same thing ?
Yes, a bit. Personally, I give the same name to name and id, there’s no problem. To link a label to a text area, we need to give it the attribute for, which has the same value as the id of the text area. Here’s what we have :
Code : HTML
Now, if you’re trying the examples at the same time as me, try clicking on username : you’ll see that the cursor automatically goes into the corresponding text area.
So…it’s just used so that the corresponding text area is selected if we click on username ?
No, not at all It also allows disabled people to easily go through the form. We don’t think about it often enough, but often our forms are so large and unorganised, that it can be hard to know what each text area is for. Here, for example, blind people will know that the text area is for the username, and they will thank you for taking the time to make things clearer with labels.
There are some other attributes for the tag which will surely interest you.
It is possible, if you want, to give a default value to a text area. To do this we just need to add the attribute value to and give it the value of the text you want to show at the beginning. Example :
Another thing : you can change the width of the text area as well as the maximum amount of characters that can be inserted in the text area. The width is defined with size. The maximum amount of characters is set with maxlength.
In the following example, the text area contains the text europcsolutions by default, the area is 30 characters long, but you can only insert 15 characters maximum :
Code : HTML
You can easily transform a text area into a password box, which is the area where visitors insert their passwords. The only thing you need to change is the type attribute in . Put type=password and it’s sorted !
I’ll complete the form. It’ll now ask the visitor for a username AND password :
Code : HTML
Now we’ll (at last) see multi line text areas. Don’t worry, it’ll be a lot faster now that we’ve seen labels Here is a multi line text area :
The tag for multi line text areas works in pairs (contrarily to ). It is . With this tag also, we add the attributes name, and use labels.
Code : HTML
We can change the size of the text area using 2 different methods :
With CSS : just apply the properties width and height to the text area. However this doesn’t work before Internet Explorer 8.With Attributes : we can add the attributes rows and cols to
pc hardware,pc store,new pc,computer hardware,pc software,pc online,computer information,online pc,hardware pc,information computer,about computer hardware,information on computer,computer hardware system,computer system hardware,information on the computer,about the computer hardware,about hardware of computer,computer & hardware
INFORMATION ON PC
pc hardware,pc store,new pc,computer hardware,pc software,pc online,computer information,online pc,hardware pc,information computer,about computer hardware,information on computer
Nessun commento:
Posta un commento