Lecturenote - 1275839844chapter 3 Part 3
Lecturenote - 1275839844chapter 3 Part 3
85FORM
HTML forms are used to select different kinds of user input.
HTML forms are used to pass data to a server.
There are two parts of working form
The first part is the form that you see on the page itself. Forms are made up of
buttons, text fields, and pull-down menus (collectively known as form controls)
used to collect information from the user
The second component of a web form is an application or script on the server that
processes the information collected by the form and returns an appropriate
response
Form Elements
Form tag
The <form> tag is used to create an HTML form:
HTML forms are used to select different kinds of user input.
HTML forms are used to pass data to a server.
There are two parts of working form
The first part is the form that you see on the page itself. Forms are made up of
buttons, text fields, and pull-down menus (collectively known as form controls)
used to collect information from the user
The second component of a web form is an application or script on the server that
processes the information collected by the form and returns an appropriate
response
Example:-
<html>
<body>
<h1>Mailing List Signup</h1>
<form action=“register.php" method="post">
</form>
</body>
1 Compiled by Tadesse K.
Fundamentals of Internet Programming 2020
</html>
Most frequently used form attributes are:
Name: This is the name of the form.
Action:
The action attribute provides the location (URL) of the application or script
(sometimes called the action page) that will be used to process the form (which
will receive uploaded data).
The action attribute in above example sends the data to a script called
register.php
.php suffix indicates that this form is processed by a php script
Method: Here you will specify method to be used to upload data (The method attribute
specifies how the information should be sent to the server). It can take various values but
most frequently used are GET and POST.
Target: It specifies the target page where the result of the script will be displayed. It
takes values like _blank, _self, _parent etc.
Enctype: You can use the enctype attribute to specify how the browser encodes the data
before it sends it to the server. Possible values are like:
application/x-www-form-urlencoded- This is the standard method most forms
use. It converts spaces to the plus sign and non-alphanumeric characters into the
hexadecimal code for that character in ASCII text.
mutlipart/form-data- This allows the data to be sent in parts, with each
consecutive part corresponding the a form control, in the order they appear in the
form. Each part can have an optional content-type header of its own indicating the
type of data for that form control.
2 Compiled by Tadesse K.
Fundamentals of Internet Programming 2020
3 Compiled by Tadesse K.
Fundamentals of Internet Programming 2020
4 Compiled by Tadesse K.
Fundamentals of Internet Programming 2020
Size: Allows you to specify the width of the text-input control in terms of
characters.
maxlength: Allows you to specify the maximum number of characters a user can
enter into the text box.
Password input controls
This is also a form of single-line text input controls are created using an <input> element
whose type attribute has a value of password.
Here is a basic example of a single-line password input used to take user password
<form action="abc.php" method="get"> Will result
User name<input type="text"
name="user_name"/><br>
Password <input type="password"
name="password"/><br>
<input type="submit" value="submit" />
</form>
Multiple-Line Text Input Controls:
If you want to allow a visitor to your site to enter more than one line of text, you should
create a multiple-line text input control using the <textarea> element.
Here is a basic example of a multi-line text input used to take item description:
<form action="abc.php" method="get"> Will result:-
Description : <br />
<textarea rows="5" cols="50" name="abc">
Enter description here...
</textarea>
<input type="submit" value="submit" />
</form>
5 Compiled by Tadesse K.
Fundamentals of Internet Programming 2020
Creating Button
There are various ways in HTML to create clickable buttons. You can create clickable
buttonusing<input> tag.
When you use the <input> element to create a button, the type of button you create
isspecified using the type attribute.
The type attribute can take the following values:
Submit: This creates a button that automatically submits a form.
Reset: This creates a button that automatically resets form controls to their initialvalues.
button: This creates a button that is used to trigger a client-side script when the
userclicks that button.
Here is the example:
<form action="abc.php" method="get">
<input type="submit" name="Submit"
value="Submit" />
<br/>
<input type="reset" value="Reset" /><br/>
<input type="button" value="Button" />
</form>
6 Compiled by Tadesse K.
Fundamentals of Internet Programming 2020
</form>
o Here srcattribiute specifies a location of the image on yourwebserver.
You can use <button> element to create various buttons. Here is the syntax:
<form> Will result
<button type="submit">Submit</button>
<br /><br />
<button type="reset"> Reset </button>
<button type="button"> Button </button></form>
Checkboxes Control:
Checkboxes are used when more than one option is required to be selected.
They are created using <input> tag
Here is example HTML code for a form with two checkboxes
<form> Will result
<input type="checkbox" name="maths"
value="on"> Maths<br>
<input type="checkbox" name="physics"
value="on"> Physics<br>
<input type="submit" value="Select Subject"/>
</form>
Following is the list of important checkbox attributes:
Type: Indicates that you want to create a checkbox.
Name: Name of the control.
Value: The value that will be used if the checkbox is selected. More than one checkbox
should share the same name only if you want to allow users to select several items from
the same list.
Checked: Indicates that when the page loads, the checkbox should be selected.
Raidobox Control:
Radio Buttons are used when only one option is required to be selected. They are created
using
7 Compiled by Tadesse K.
Fundamentals of Internet Programming 2020
<input> tag as shown below:
Here is example HTML code for a form with two radio button
<form action="abc.php" method="post"> Will result
<input type="radio" name="subject" value="maths" />Maths<br>
<input type="radio" name="subject" value="physics" />
Physics<br>
<input type="submit" value="Select Subject" />
</form>
9 Compiled by Tadesse K.
Fundamentals of Internet Programming 2020
</form>
10 Compiled by Tadesse K.
Fundamentals of Internet Programming 2020
Many questions come up over how a page is loaded, and a lot of that canbe answered by
the way the protocol that transports the page from theserver to the web client works.
Web servers and web client software will support HTTP 1.1, which has several
enhancements over HTTP 1.0. The major enhancement is that only one connection will
be established for the page and all the elements that need to be downloaded. This will
reduce the number of connections that must be opened and maintained, at the server and
will decrease download time.
Browser Compatibility
Web client software is written by a number of companies and as such there are a number
of differences between the browsers in the way that they interpret standard HTML code.
One difference is the way in which the browsers draw tables. Internet Explorer will
redisplay the table as new elements fill in the cells. Navigator 4 downloads all the
elements before displaying the table and so does not perform multiple redraws as the
table fills with data.olm.net
Page layout
Page Layout Guidelines
1. In most cases your pages should not require the viewer to scroll to the right. The maximum
width of a page should be 600 pixels in order to be displayed properly, regardless of the display
resolution.
2. Recommended components of a home page:
i. E-mail address (i.e. [email protected])
ii. Mailing address
iii. Phone numbers
iv. Interactive component that encourages repeat visits by your target audience
v. Look, feel and message should reflect the organization
vi. Information that is relevant to the target audience
vii. Directions to what your target audience wants to know or do
3. To control a page you may want to create a table with a maximum sizeof 600 pixels and
contain the page inside the table.o.com 147
11 Compiled by Tadesse K.
Fundamentals of Internet Programming 2020
4. When deciding to use a Background Image that has a distinct left sideyou should make sure it
is 1280 pixels wide, because the browser tilesthe background image, and anything smaller will
appear again on theright of the page when viewed at high resolutions.
5. Use the DIV and CENTER element to control layout. (Div createsdivisions within the
document that do not have preformatted spacingassociated with them, like paragraphs) You can
control the alignmentof objects with the alignment attribute of the DIV element.
6. To create attractive looking forms you should use a table to control thelayout and alignment of
the form elements.
7. Web pages should use white space at the borders. This makes thepages easier to look at and to
read. Printed pages usually have whitespace at the left and right hand sides; as well, at the top
and bottom ofthe page. This effect can be achieved by centering the contents of thepage.
8. Frames are good for keeping people in your site. Careful considerationmust be given to using
Frames, as they require Frames-capablebrowsers. Always remember to provide valuable
information in theNoFrames section of the Frameset.
9. You should be consistent in your layout across multiple pages, peoplebecome comfortable
with the format, and begin to expect it.
10. Bigger is better. If things are too small they will strain the viewer’seyes and it will not be
comfortable for them.
11. You should vary sizes for texture. When everything is the same size itbecomes very boring.
12. Blinking text should only be used in situations where the information ischanging frequently.
13. be sure to use case properly. Mix upper and lower case as required orfor effect. Documents
done in all UPPER case are hard to read.148 O
12 Compiled by Tadesse K.
Fundamentals of Internet Programming 2020
13 Compiled by Tadesse K.