Content of the lesson:
Almost everyone has already seen a form inside a page. You have to fill in a registration form when creating a mailbox at servers like Google, Seznam, Atlas etc. You write required information and send it (usually by clicking on a Send button). After clicking on this button, all information is sent to server and it is usually checked (if everything was filled, if data are meaningful, ...). The same form can be displayed again in case there are several errors or data can be saved to a database on the server.
The creation of web forms consists of two steps:
A form can be inserted between tags <form> and </form>. It also needs 2 attributes:
<form action="processform.php" method="get">
content of form (text arrays, switches, ...)
</form>
The attribute method sets the way of transferring data from form to server. You can choose any method but you should consider the following limitations:
Take a look at the mostly used form elements.
<input name="name-of-textbox" type="text" value="default-text" size="20" />
<textarea name="longer-textbox" cols="30" rows="10">
<input name="zaskrtavaci-poleA" type="checkbox" value="checked" checked="checked" />A
<input name="zaskrtavaci-poleB" type="checkbox" value="unchecked" />B
<input name="vyberove-pole" type="radio" value="A" checked="checked" />A
<input name="vyberove-pole" type="radio" value="B" />B
<input name="vyberove-pole" type="radio" value="C" />C
<select name="list">
<option value="A">A</option>
<option value="B" selected="selected">B</option>
<option value="C">C</option>
</select>
You should also know the submit bottom. This button is used to submit data from the form (to be able to send them, without this element you cannot send any data). After clicking on this button inside this page you send this form with this button using the GET method.
<input name="odeslat-formular" type="submit" value="Send the form" />
There are more possible elements and we will talk about them later.
Create a simple HTML form which will be used to register a new user to a discussion server. The form will contain the following data:
Choose proper form elements for each of these details and try using both get and post methods (try their behavior after pressing F5 in your browser). The form can look like the following one:
Is this form complete?
1. Describe at least two possibilities of forms notations in HTML (help: tables, attribute label, tags dl, dt and dd). Illustrate their usage on the previous registration form and discuss the individual solutions.
2. Try to find current online sources dealing with the problem of styling forms using CSS. Summarize found information and write used sources. Try to suggest a set of CSS styles for the previous registration form.