2-Frames and Forms (Unit-2)
2-Frames and Forms (Unit-2)
2-Frames and Forms (Unit-2)
KCS-602
by
❑ FRAMES
❑ FORMS
FRAMES
▪ Frames gives us a way to merge multiple HTML Documents in a single HTML Document.
▪ A framed page is actually made up of multiple HTML pages.
▪ There is one HTML document that describes how to break up the single browser window into multiple windowpanes.
▪ Each windowpane is filled with an HTML document.
For Example : to make a framed page with a windowpane on the left and one on the right requires 3 HTML pages.
▪ A <FRAMESET> element is placed in the html document before the <BODY> element.
▪ <frameset>) element is used instead of HTML Body (<body>) tag to split the browser screen into multiple pane
▪ The <FRAMESET> provides measurement to each windowpane by dividing the screen into ROWS or COLS.
▪ The <FRAMESET> will then contain <FRAME> elements, one per division of the browser window(each pane).
Frame Page Architecture
Ex:
<HTML>
<HEAD>
<TITLE> Framed Page </TITLE>
o/p:
<FRAMESET COLS="50%,50%">
<frame src="https://www.kiet.edu">
<frame src="https://www.javatpoint.com">
</FRAMESET >
</HEAD>
</HTML>
Graphical view of the prev. document :
<FRAMESET> : The FRAMESET element creates divisions in the browser window either in rows or columns
▪ ROWS : Determines the size and number of rectangular rows within a <FRAMESET>. They are set from top of the
display area to the bottom.
▪ COLS: Determines the size and number of rectangular columns within a <FRAMESET>. They are set from left to right of
the display area.
▪ FRAMEBORDER : Possible values 0, 1, YES, NO. A setting of zero will create a borderless frame.
▪ FRAMESPACING: This attribute is specified in pixels. If you go to borderless frames you will need to set
this value to zero as well, or you will have a gap between your frames where the border used to be.
▪ BORDER(thickness of the Frame): This attribute specified in pixels. A setting of zero will create a
borderless frame. Default value is 5.
▪ BORDERCOLOR: Allows to choose a color for the border.
<FRAME>
<FRAME>: This element defines a single frame within a frameset. There will be a FRAME
element for each division created by the FRAMESET element. This tag has the following
attributes:
▪ SRC: Required, as it provides the URL for the page that will be displayed in the frame.
▪ NAME: Required for frames that will allow targeting by other HTML documents. Works in
conjunction with the target attribute of the <A>, <AREA>, <BASE>, and <FORM> tags.
<FRAME>
▪ <NOFRAMES>: Frame – capable browsers ignore all HTML within this tag including the
contents of the BODY element. This element does not have any attributes.
<HTML>
<HEAD>
<TITLE> Framed Page </TITLE>
</HEAD>
▪ In this case a second FRAMESET element will be inserted in the place of the FRAME
element that would describe the second row.
▪ The second FRAMESET element will divide the remaining screen real estate into 2 columns.
▪ This nested FRAMESET will then be followed by 2 FRAME elements to describe each of the
subsequent frame divisions created.
<html>
<noframes>
<head> <p>
<title> Compound Frames Page</title> Default message
</head> </p>
<frameset rows=“120,*”> </noframes>
<frame src="d:\diya.png" name="d"> </frameset>
<frameset cols=“120,*”> </frameset>
</head>
<frame src="https://www.kiet.edu" name="k">
<frame src="assign1.txt" name="a">
Compound FRAMESET Divisions
(A frames design with a combination of rows and columns)
WELCOME
KIET
ASSIGN
Frame Formatting
Example:
<HTML> <HEAD> O/P:
<TITLE> Framed Page </TITLE> </head>
<frameset rows="30%,50%,*" frameborder="1">
<frame src="assign1.txt" scrolling="auto">
<frame src="d:\diya.png" noresize scrolling="no">
<frame src="https://www.kiet.edu" noresize scrolling="no">
</frameset>
</head>
</HTML>
TARGETS
▪ When links are used in a frame, we need to specify an additional attribute called TARGET.
▪ The TARGET attribute uses the NAME attribute of the FRAME element.
▪ If we were to place a link in doc1.html that linked to doc3.html and we wanted doc3.html to be
displayed in the right windowpane; the HTML code would appear in doc1.html as follows:
STEP DESC
<html><head>
File: frame.html </head>
<frameset cols="30%,*" frameborder="1">
<frame src="d:\linkbyname.html" name="left">
<frameset rows="20%,50%,30%">
<frame src="" name="top">
<frame src="" name="middle">
<frame src="" name="bottom">
</frameset></frameset>
</html>
Cont….
File: linkbyname.html
<html><head>
<title>Link by name</title></head>
<h3> CLICK INDEX</h3><br><br><br>
</html>
OUTPUT: Targeting links to frames
(1)
(2)
Special Targets
There are 4 special target names that cannot be assigned by the NAME attribute of the FRAME tag.
1. TARGET=“_top” : Loads the linked document into the full browser window with the URL specified
by the HREF attribute. All frames disappear, leaving the new linked page to occupy the entire
window. The back is turned on.
2. TARGET=“_blank” : Loads the document specified in the URL attribute into the new window. The
back is turned off. Other windows remains on.
3. TARGET=“_self” : Loads the document in the same window where the anchor was {Clicked}. This is
the default setting for linking elements.
STEP DESC
<html><head>
File: frame.html </head>
<frameset cols="30%,*" frameborder="1">
<frame src="d:\linkby4target.html" name="left">
<frameset rows="20%,50%,30%">
<frame src="" name="top">
<frame src="" name="middle">
<frame src="" name="bottom">
</frameset></frameset>
</html>
Cont….
File: linkby4target.html
<html>
<head>
<title>Link by system Target </title>
</head>
<h3> CLICK INDEX</h3><br><br><br>
<a href="d:\welcome.html" target="_blank">WELCOME</a><br><br>
<a href="d:\diya.png" target="_self">DEEPJYOTI</a><br><br>
<a href="https://www.kiet.edu" target="_parent">KIET</a><br><br>
<a href="https://google.com" target="_top">GOOGLE</a><br><br>
</html>
FORMS
❖ Facilitates the user to enter data that is to be sent to the server for processing such as name, email
address, password, phone number, etc. .
❖ Used to collect information from people viewing our site
▪ METHOD attribute indicates the way the Web server will organize and send you form output.
▪ ACTION attribute :
• Path to a script
• <input type="text"> defines a one-line input field that a user can enter text into:
<form>
</form>
Note: The form itself is not visible. Also note that the default width of a text field is 25 characters.
(2) Password Field
<form>
</form>
Note: The characters in a password field are masked (shown as asterisks or circles).
(3) Radio Buttons
• Radio buttons let a user select ONLY ONE of a limited number of choices.
<form>
<input type="radio" name="gender" value="male">Male<br>
<input type="radio" name="gender" value="female">Female
</form>
<form>
<input type="checkbox" name=“java" value=“java"> I know JAVA<br>
<input type="checkbox" name="vehicle" value="Car"> I know PYTHON
</form>
NOTE: If you type some characters in the text field above, and click the "Submit" button, the browser will
send your input to a page called "html_form_action.asp". The page will show you the received input
(6) Reset Button
<HTML>
EXAMPLE: <HEAD><TITLE> Forms II</TITLE></HEAD>
<BODY>
<H2>Feedback Form</H2>
<P>Please fill out this form to help us improve our site.</P>
<FORM METHOD = "POST" ACTION = "/cgi-bin/formmail">
<INPUT TYPE = "hidden" NAME = "recipient" VALUE = “[email protected]">
<INPUT TYPE = "hidden" NAME = "subject" VALUE = "Feedback Form">
<INPUT TYPE = "hidden" NAME = "redirect" VALUE = "main.html">
<P><STRONG>Name: </STRONG>
<INPUT NAME = "name" TYPE = "text" SIZE = "25"></P>
<P><STRONG>Comments:</STRONG>
<TEXTAREA NAME = "comments" ROWS = "4" COLS = "36"></TEXTAREA>
</P>
<P><STRONG>Email Address:</STRONG>
<INPUT NAME = "email" TYPE = "password" SIZE = "25"></P>
EXAMPLE cont….:
<P><STRONG>Things you liked:</STRONG><BR>
Site design <INPUT NAME="things" TYPE="checkbox" VALUE="Design">
Links <INPUT NAME="things" TYPE="checkbox" VALUE="Links">
Ease of use <INPUT NAME="things" TYPE="checkbox" VALUE="Ease">
Images <INPUT NAME="things" TYPE="checkbox" VALUE="Images">
Source code <INPUT NAME="things" TYPE="checkbox" VALUE="Code"></P>
<P><STRONG>How did you get to our site?:</STRONG><BR>
Search engine
<INPUT NAME="how get to site" TYPE="radio" VALUE="search engine" CHECKED>
Links from another site
<INPUT NAME="how get to site" TYPE="radio" VALUE="link">
Deitel.com Web site
<INPUT NAME="how get to site" TYPE="radio" VALUE="deitel.com">
Reference in a book
<INPUT NAME="how get to site" TYPE="radio" VALUE="book">
Other
<INPUT NAME="how get to site" TYPE="radio" VALUE="other"></P>
EXAMPLE cont.….. : <P><STRONG>Rate our site (1-10):</STRONG>
<SELECT NAME = "rating">
<OPTION SELECTED>Amazing:-)
<OPTION>10
<OPTION>9
<OPTION>8
<OPTION>7
<OPTION>6
<OPTION>5
<OPTION>4
<OPTION>3
<OPTION>2
<OPTION>1
<OPTION>The Pits:-(
</SELECT></P>