html : forms, frames instructor: mr. ahmed al astal itgd4104 department requirement for senior...

18
HTML : Forms, Frames Instructor: Mr. Ahmed Al Astal ITGD4104 Department Requirement for senior student University of Palestine Faculty of IT

Upload: brianna-higgins

Post on 13-Jan-2016

224 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: HTML : Forms, Frames Instructor: Mr. Ahmed Al Astal ITGD4104 Department Requirement for senior student University of Palestine Faculty of IT

HTML : Forms, Frames Instructor: Mr. Ahmed Al Astal

ITGD4104

Department Requirement for senior student

University of Palestine

Faculty of IT

Page 2: HTML : Forms, Frames Instructor: Mr. Ahmed Al Astal ITGD4104 Department Requirement for senior student University of Palestine Faculty of IT

2

• A form is an area that can contain form elements.

• Form elements are elements that allow the user to enter information (like text fields, textarea fields, drop-down menus, radio buttons, checkboxes, etc.) in a form.

• A form is defined with the <form> tag.

<form>.input elements.</form>

WEB PROGRAMMING : Forms

Page 3: HTML : Forms, Frames Instructor: Mr. Ahmed Al Astal ITGD4104 Department Requirement for senior student University of Palestine Faculty of IT

3

HTML <form> method Attribute

• The method attribute specifies how to send form-data (the form-data is sent to the page specified in the action attribute).

• The form-data can be sent as

• URL variables (with method="get")

• or as HTTP post (with method="post").

WEB PROGRAMMING : Forms

Page 4: HTML : Forms, Frames Instructor: Mr. Ahmed Al Astal ITGD4104 Department Requirement for senior student University of Palestine Faculty of IT

4

Input

• The most used form tag is the <input> tag.

• The type of input is specified with the type attribute.

• The most commonly used input types are explained below:

Text Fields

• Text fields are used when you want the user to type letters, numbers, etc. in a form.

<form>First name:

<input type="text" name="firstname" /><br />

Last name:<input type="text" name="lastname" />

</form>

WEB PROGRAMMING : Forms

Page 5: HTML : Forms, Frames Instructor: Mr. Ahmed Al Astal ITGD4104 Department Requirement for senior student University of Palestine Faculty of IT

5

Radio Buttons

• Radio Buttons are used when you want the user to select one of a limited number of choices.

<form>

<input type="radio" name="sex" value="male" /> Male

<br />

<input type="radio" name="sex" value="female" /> Female

</form>

WEB PROGRAMMING : Forms

Page 6: HTML : Forms, Frames Instructor: Mr. Ahmed Al Astal ITGD4104 Department Requirement for senior student University of Palestine Faculty of IT

6

Checkboxes

• Checkboxes are used when you want the user to select one or more options of a limited number of choices .

<form>

I have a bike:

<input type="checkbox" name="vehicle" value="Bike" />

<br />

I have a car:

<input type="checkbox" name="vehicle" value="Car" />

<br />

I have an airplane:

<input type="checkbox" name="vehicle" value="Airplane" />

</form>

WEB PROGRAMMING : Forms

Page 7: HTML : Forms, Frames Instructor: Mr. Ahmed Al Astal ITGD4104 Department Requirement for senior student University of Palestine Faculty of IT

7

The Form's Action Attribute and the Submit Button

1. When the user clicks on the "Submit" button, the content of the form is sent to the server.

2. The form's action attribute defines the name of the file to send the content to.

3. The file defined in the action attribute usually does something with the received input

<form name="input" action="html_form_submit.asp" method="get">

Username:

<input type="text" name="user" />

<input type="submit" value="Submit" />

</form>

WEB PROGRAMMING : Forms

Page 8: HTML : Forms, Frames Instructor: Mr. Ahmed Al Astal ITGD4104 Department Requirement for senior student University of Palestine Faculty of IT

8

Form Tages

WEB PROGRAMMING : Forms

Page 9: HTML : Forms, Frames Instructor: Mr. Ahmed Al Astal ITGD4104 Department Requirement for senior student University of Palestine Faculty of IT

9

Worked Example<html><body><form action="MAILTO:[email protected]" method="post" enctype="text/plain">

<h3>This form is an example.</h3>Name:<br><input type="text" name="name“ value="yourname" size="20"><br>Mail:<br><input type="text" name="mail“ value="yourmail" size="20"><br>Comment:<br><input type="text" name="comment“ value="yourcomment" size="40"><br><br><input type="submit" value="Send"><input type="reset" value="Reset">

</form></body></html>

WEB PROGRAMMING : Forms

Page 10: HTML : Forms, Frames Instructor: Mr. Ahmed Al Astal ITGD4104 Department Requirement for senior student University of Palestine Faculty of IT

10

Frames• With frames, you can display more than one Web page in

the same browser window.

• Each HTML document is called a frame, and each frame is independent of the others.

• The disadvantages of using frames are:

• The web developer must keep track of more HTML documents

• It is difficult to print the entire page

WEB PROGRAMMING : Frames

Page 11: HTML : Forms, Frames Instructor: Mr. Ahmed Al Astal ITGD4104 Department Requirement for senior student University of Palestine Faculty of IT

11

The Frameset Tag

• The <frameset> tag defines how to divide the window into frames

• Each frameset defines a set of rows or columns

• The values of the rows/columns indicate the amount of screen area each row/column will occupy

The Frame Tag

• The <frame> tag defines what HTML document to put into each frame

WEB PROGRAMMING : Frames

Page 12: HTML : Forms, Frames Instructor: Mr. Ahmed Al Astal ITGD4104 Department Requirement for senior student University of Palestine Faculty of IT

12

In the example below we have a frameset with two columns.

The first column is set to 25% of the width of the browser window.

The second column is set to 75% of the width of the browser window.

The HTML document "frame_a.htm" is put into the first column, and the HTML document "frame_b.htm" is put into the second column:

<frameset cols="25%,75%">

<frame src="frame_a.htm">

<frame src="frame_b.htm">

</frameset>

WEB PROGRAMMING : Frames

Page 13: HTML : Forms, Frames Instructor: Mr. Ahmed Al Astal ITGD4104 Department Requirement for senior student University of Palestine Faculty of IT

13

Basic Notes

If a frame has visible borders, the user can resize it by dragging the border. To prevent a user from doing this, you can add noresize="noresize" to the <frame> tag.

Important: You cannot use the <body></body> tags together with the <frameset></frameset> tags! However, if you add a <noframes> tag containing some text for browsers that do not support frames, you will have to enclose the text in <body></body> tags! See how it is done in the first example below.

WEB PROGRAMMING : Frames

Page 14: HTML : Forms, Frames Instructor: Mr. Ahmed Al Astal ITGD4104 Department Requirement for senior student University of Palestine Faculty of IT

14

Examples

How to create a vertical frameset with 3 different documents:

<html>

<frameset cols="25%,50%,25%">

<frame src="frame_a.htm"> <frame src="frame_b.htm"> <frame src="frame_c.htm">

</frameset>

</html>

WEB PROGRAMMING : Frames

Page 15: HTML : Forms, Frames Instructor: Mr. Ahmed Al Astal ITGD4104 Department Requirement for senior student University of Palestine Faculty of IT

15

Examples

How to create a horizontal frameset with 3 different documents

<html>

<frameset rows="25%,50%,25%">

<frame src="frame_a.htm">

<frame src="frame_b.htm">

<frame src="frame_c.htm">

</frameset>

</html>

WEB PROGRAMMING : Frames

Page 16: HTML : Forms, Frames Instructor: Mr. Ahmed Al Astal ITGD4104 Department Requirement for senior student University of Palestine Faculty of IT

16

Examples

How to mix a frameset in rows and columns

<html>

<frameset rows="50%,50%">

<frame src="frame_a.htm">

<frameset cols="25%,75%">

<frame src="frame_b.htm">

<frame src="frame_c.htm">

</frameset>

</frameset>

</html>

WEB PROGRAMMING : Frames

Page 17: HTML : Forms, Frames Instructor: Mr. Ahmed Al Astal ITGD4104 Department Requirement for senior student University of Palestine Faculty of IT

17

THE HTML DOCUMENT HEAD IN DETAIL

• The head is a very important part of any HTML page: it contains lots of control information that is needed by browsers and servers.

• If you want to use scripts or style sheets, or provide information to search engines, then the simple head section is not appropriate:

• You need to use some of the tags that are discussed later

WEB PROGRAMMING : Frames

Page 18: HTML : Forms, Frames Instructor: Mr. Ahmed Al Astal ITGD4104 Department Requirement for senior student University of Palestine Faculty of IT

18

Document Type Declarations

• Before the initial <html> tag the type of the document should be specified so that SGML tools can understand it.

• The document type declaration for basic HTML is:

<! doctype html public "-//w3c//dtd html 4.0//en“

"http://www.w3.org/TR/PR-htm!4.0/loose.dtd" >

WEB PROGRAMMING : Frames