0% found this document useful (0 votes)
12 views241 pages

web programming

This document is a textbook for a B.Com. course on Web Programming, authored by Venu P. It includes a detailed syllabus covering HTML, VBScript, DHTML, ASP, and XML, along with practical exercises and model papers. The book is published by Apoorva Publishers and is priced at Rs. 155.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views241 pages

web programming

This document is a textbook for a B.Com. course on Web Programming, authored by Venu P. It includes a detailed syllabus covering HTML, VBScript, DHTML, ASP, and XML, along with practical exercises and model papers. The book is published by Apoorva Publishers and is priced at Rs. 155.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 241

Apoorva Publishers 1

B.Com., Computer Applications


Final year

WEB PROGRAMMING
(As per the new syllabus and revised examination)

By:
Venu P. B.E. Comp.

APOORVA DEGREE COLLEGE


DISC COMPUTERS
Karimnagar.

B- Com III – Web Programming


2 Apoorva Publishers

For Copies Contact:


Srinivasa book depot: 9848535542

Published by:
DISC Computers.
Apoorva Degree College.

Price Rs. 155/- only

In spite of many efforts taken to present the book


without errors, some errors might have crept in.
Therefore, we do not take any responsibility for such
errors and omissions. However if they are brought to our
notice, they will be corrected in the new edition.

No part of this book may be reproduced, stored in any


retrieval system or otherwise without the prior
permission of the author.

B- Com III - Web Programming


Apoorva Publishers 3

Web Programming -CONTENTS PAGENO


Syllabus 4
QUESTIONS & ANSWERS 5
UNIT I
HTML 5
UNIT II
VBScript 51
UNIT III
DHTML 96
UNIT IV
ASP 131
UNIT V
XML 164
Practical Question Bank 193
HTML Programs 194
VBScript Programs 206
ASP Programs 212
XML Programs 215
VIVA & SHORT questions 217
Model Paper-1 236
Model Paper-2 237
2011 March Paper 238
2012 March Paper 239
2013 March Paper 240
2014 March Paper 241

B- Com III – Web Programming


4 Apoorva Publishers

SYLLABUS
WEB PROGRAMMING
Max. Marks : 100 (Theory 70 + Practical 30)

UNIT - I:
HTML Programming Introduction - Formatting Text-Forms & Formulating Elements -
Graphics in HTML Creating Tables & Frames - Web Design Principles.

UNIT- II :
VB Scripting Introduction - VB Script - Basics of VB Script - Array Handling - User Interaction
in VB Script - Data Validation in VB Script - Handling Runtime Errors.

UNIT - III :
Dynamic HTML Programming Introduction - Cascading Style Sheets (CSS) - Events Handling -
Changing Text and Attributes - Dynamically Changing Style, Text, Graphics and Placements -
Creating Multimedia Effects with Filters and Transitions.

UNIT - IV:
Active Server Pages (ASP) Introduction - Scripting Languages and Script Engines in ASP - ASP
Objects - Data Access Technology - ASP Application - Information Search Tools.

UNIT- V :
Extensible Markup Language (XML) Introduction - Creating XML Documents - XML Style
Sheets - Hyperlinks in XML Documents - XML Document Object Model - XML Query
Language.

Lab Work:
Creation of a Web site with Dynamic functionality using client-side and server - side
scripting.

Suggested Reading:
1. Microsoft Official Curriculum.
2. Essential XML : Box
3. Dynamic HTML : Rule
4. HTML for the WWW : Castro

B- Com III - Web Programming


Apoorva Publishers 5

1 HTML
1. What is HTML? Explain its Advantages and Disadvantages.
2. What is a Tag? Explain Tag Properties.
3. What is the structure of a HTML page?
4. What are Attributes? What are the Common or Standard Attributes of HTML tags?
5. Explain the attributes of <BODY> tag.
6. Explain <HEAD> tag in detail. (OR) Explain HEAD section in a HTML document. (OR)
What tags can be included in <HEAD> tag?
7. What are Text (Character) formatting tags in HTML? (Or) What are Physical Tags in
HTML?
8. Write about Paragraph Formatting tags.
9. Explain different Formatting tags in HTML?
10. What are Logical Tags in HTML? Explain.
11. Distinguish between Physical HTML style tags and Logical HTML style tags. (Or)
Distinguish between Dependent Tags and Independent Tags with two examples for
each tag.
12. Write about different Heading tags.
13. How do you write Comments in HTML documents?
14. Write short notes on <FONT> tag.
15. Write short notes on <MARQUEE> tag. And explain its attributes. (Or) How to
create scrolling text/images in HTML?
16. Write short notes on <IMG> (Image) tag. (Or) How to add images to HTML pages?
17. How do you place objects or multimedia content in HTML pages? (Or) How do you
play Audio and Video files in HTML?
18. Explain Graphics of HTML with the help of an example.
19. Explain ALIGN attribute in images. (Or) How do you align Images with respect to
text?
20. What is Image Mapping? (Or) Write short notes on <MAP> and <AREA >tags.
21. Write about different types of Lists in HTML.
22. Write about <TABLE> tag. (Or) How do you create tables in HTML?
23. Using table and its sub-tags Design a Students Marks Memorandum
24. Using table and its sub-tags create the following table.
25. Explain the table alignment attributes and cell alignment attributes. (Or) Explain
horizontal and vertical alignment in Tables with an example.
26. Write about Column spanning and Row spanning in tables with an example. (Or)
Explain Spanning columns and Rows in a table with the help of an example.

B- Com III – Web Programming


6 Apoorva Publishers
27. Explain how to create a table and design the Border, Horizontal, Vertical
alignment, Spanning columns and Rows in a table with the help of an example.
28. How do you create links in HTML? (Or) Write about <a href> tag
29. What are the attributes used in Anchor (<a>) tag.
30. Write short notes on ‘target’ attribute of anchor tag. (Or) Explain how to open
documents trough hyperlinks in different ways (targets)
31. How do you make an image as a hyperlink? (Or) How to create Graphical
Hyperlinks in HTML? Give an example.
32. Write about Background animations in HTML pages. (Or) Write about background
images and sounds.
33. What are Form Elements (Components)? Explain. (Or) Explain <FORM> tag in detail.
34. Expalin how to create different form elements with code.
35. Explain <INPUT> tag in detail.
36. Write short notes on <LEGEND> and <FIELDSET> tags.
37. Write short notes on <FRAME> tag. (Or) Explain Frames in HTML? (Or) What is a
Frameset? Explain how to create Horizontal and Vertical Frames.
38. What are nested Frames?
39. Create the following Frameset.
40. Using tables and Frames Design the following web page:
41. What are Inline Frames?
42. Write the difference between a table and frame. Write a program to print the
different courses offered by an educational institutions using table.
43. Explain the tags: <HR>, <SPACER>, <BANNER>, <LAYER>
44. Explain the tags: <BODY>, <FONT>, <MARQUEE>, <BASEFONT> with minimum 2-3
attributes.
45. Explain the tags: <SMALL>, <HEAD>, <MARQUEE>, and <A HREF>.
46. Explain the tags: <EM>, <CODE>, <VAR>, <ABBR>, <ACRONYM>, and <KBD>.
47. Explain the tags: <MARQUEE>, <TABLE>, <BLINK>, and <MULTICOL>
48. What are the main steps involved in creating a webpage and how does it get
executed? (Or) Explain the procedure to create HTML document.
49. Explain the characteristics of Web Images in HTML?
50. Discuss about good Web Design principles.
51. What is the difference between a web page and ordinary file document?
52. Define WWW? (Or) What is Web?
53. Define a Webpage. Give an Example.
54. List common Image File Formats.

B- Com III - Web Programming


Apoorva Publishers 7
1. What is HTML? Explain its Advantages and Disadvantages.

HTML: HTML stands for Hyper-Text Markup Language. It allows us to create web pages.
It does not include any control structure and can produce only static content. A HTML
page consists of various tags that make a web page. The features, advantages and
disadvantages of HTML page are listed below.

Features of HTML:
 It is a formatting language for text and images.
 It allows us to read the content nonlinearly by using hyperlinks to a file.
 HTML is an application of SGML.
 HTML uses markup tags to describe web pages
 It is not case sensitive i.e. code can be written in small case or uppercase letters.
 All the HTML documents have “.html” or “.htm” extension.
 HTML documents can be edited using editors such as notepad or front page.

The advantages of HTML:


 It allows embedding scripts, to generate dynamic content
 It can incorporate images and sounds with the help of HTML tags.
 It facilitates Moving and layered text
 It allows framed documents
 It allows absolute positioning of text and image.
 Spreadsheets, video clips, pdf files can be embedded in HTML documents with the
support of third party plug-ins.

The disadvantages of HTML:


 HTML can produce only static content
 It does not facilitate headers, footers, footnotes.
 Mathematical typesetting is difficult
 Browser Dependent
 No tabs and other automatic character spacing

2. What is a Tag? Explain Tag Properties.

HTML Tags: HTML uses markup tags to describe web pages. HTML markup tags are
usually called HTML tags. The properties of tags are listed below.

 HTML tags are keywords surrounded by angle brackets as in <tag-name>


 HTML tags normally come in pairs like <tag-name> and </tag-name>, such tags are
called paired tags.
 The first tag in a pair is the start tag, the second tag is the end tag

B- Com III – Web Programming


8 Apoorva Publishers
 Start and end tags are also called opening tags and closing tags.
 Some of the tags have only opening tag. These are called empty tags like <BR>,
<HR>.
 Each tag may have attributes in them as in <font color=’red’>, here color is
attribute and ‘red’ is its value.
 No tag in HTML is mandatory. But, a well written HTML document has <HTML>,
<HEAD> and <BODY> tags.
 Tags are not case sensitive i.e. they may be written in lower or upper case letters.
 Some tags can also be nested within other tags; for example:
<H1> This is my <B> Computer </B> Notes </H1>
 If a browser cannot interpret a tag, it will be simply ignored.
 Tags are also called elements of a HTML document.

Element

<H1 ALIGN = “CENTER” > APOORVA COLLEGE </H1>


Attribute End Tag
Start Tag
Example: The following program uses two tags: <BODY> and <H1>
<BODY>
<H1> Hello </H1>
</BODY>

3. What is the structure of a HTML page?

A HTML document is basically separated in two parts: the head (HTML head tag) and
the body (HTML body tag). We also add a Document type declaration on top of it to get
the basic document structure and HTML version. The structure of a HTML document is
shown below.

Structure of HTML program:


<! DOCTYPE …> version information
<HTML>
<HEAD>
...information about document, scripts, styles….
</HEAD>
<BODY>
...visible content of document….
</BODY>
</HTML>

B- Com III - Web Programming


Apoorva Publishers 9
 The !DOCTYPE declaration: Every well written HTML document begins with a basic
declaration that defines what type of document it is. This declaration is made using
the!DOCTYPE tag and is to be written at the beginning of the document. It tellS the
processing agent and HTML version. Sample is shown below.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">

 <HTML> tag: The html tag acts as a container for the whole document. Every
character in the document should be in between the html start and end tags. The
html tag can also be used to define the language of the contained document
through the "lang" attribute. The content of the html tag is divided in two parts
using the head (HTML head tag) and the body (HTML body tag).

 <HEAD> tag: This section is the document's head. All the information contained in
the document's head is loaded first, before any other thing in the document, as it's
defined before the body segment. It includes tags like title, script, style, meta and
so on.

 <BODY> tag: This is the document's body: The body is the container for the visual
part of a document. All the things written here will be shown when the document
is rendered. Most of the tags in HTML can be inserted in the body section (inside
the HTML body tag) and will take care of the visual aspects of the document.

Example:
<HTML>
<HEAD>
<TITLE> My first Page </TITLE>
</HEAD>
<BODY>
<H1> Hello HTML <H1>
</BODY>
</HTML>

4. What are Attributes? What are the Common or Standard Attributes of HTML tags?

Attributes: Attributes provide additional information about an element (tag). All the
tags can have attributes. And these attributes are always specified in the start tag. The
following are the characteristics of attributes.
 Attributes have default values
 Attributes come in name/value pairs like: attribute-name="value"
 There are some valueless attributes like ‘checked’ in <input> tag.
 Some of the attributes are required in some of the tags. For example, ‘src’
attribute of <IMG> tag is mandatory.

B- Com III – Web Programming


10 Apoorva Publishers
 Attribute names and attribute values are case-insensitive.
 Below is a list of some attributes that are standard for most HTML elements (i.e.
except for- base, head, html, meta, param, script, style, and title elements)

Attribute Value Description


class classname Specifies a classname for an element
id id Specifies a unique id for an element
style style_definition Specifies an inline style for an element
title tooltip_text Specifies extra information about an element
(displayed as a tool tip)

Example: The following <FONT> tag uses ‘color’ and ‘size’ attributes.
<font color=’red’ size=8> Hello APOORVA </font>

5. Explain the attributes of <BODY> tag.

<BODY> tag: This is the document's body: The body is the container for the visual part
of a document. All the things written here will be shown when the document is
rendered. Most of the tags in HTML can be inserted in the body section (inside the
HTML body tag) and will take care of the visual aspects of the document.

When we create a Web page, we can change several visual characteristics in the body
of the document by adding extra attributes to the <body> tag. Following are the
different attributes, which can be used in BODY tag.

 Bgcolor: This changes the background color of the page. We can set this to any
color we would like to use. We can give color name or hex code.
 Text: This changes the default text color in the page. Here also, we can give color
name or hex code.
 Link: This changes the color of all the non-visited links on the page.
 Alink : This changes the color of an active link on the page, which is a link that has
just been clicked on by a user.
 Vlink: This changes the color of a visited link on the page
 Background: This adds a background image to the page. If we don't use a
background image, the browser will use the background color or its default
background color.

Example: Following code uses the above attributes in the body tag.

<body bgcolor="black" text="red" link="yellow"


alink="orange" vlink="red" background="logo.gif">

B- Com III - Web Programming


Apoorva Publishers 11
6. Explain <HEAD> tag in detail. (OR) Explain HEAD section in a HTML document. (OR) What
tags can be included in <HEAD> tag?

<HEAD> tag: This section is the document's head. All the information contained in the
document's head is loaded first, before any other thing in the document, as it's defined
before the body segment. It includes tags like title, script, style, meta, base, basetag,
index and so on.

 <TITLE> tag: This is the document's title. This is displayed in the title bar of the
window.
 <STYLE> tag: This is used to write style specifications. It includes a group of class
definitions (style sheets) used by other tags to set visual characteristics.
 <SCRIPT> tag: This allows defining script functions which are of VBScript and
JavaScript.
 <META> tag: This has information about data. This sets custom attributes and
values for the document.
 <LNIK> tag: This is used to specify global links. This specifies relationships with
other documents.
 <ISINDEX> tag: This is for simple keyword searches
 <BASE tag>: This defines default address/directory for the links in a HTML page.
 <BASEFONT> tag: This tag specifies a default font-color, font-size, or font-family
for all the text in a document.

Example: Following <HEAD> tag uses the above tags.

<head>
<title> C Notes </title>
<meta name="Author" content="Venu" />
<base href=“http://winningbrains.com/images/” />
<basefont color="red" size="5" />
<style>
table
{
border-width: 100%;
border-color: blue;
}
</style>
<script language="VBScript">
sub sayhi
msgbox "hi"
end sub
</script>
<link rel="index" href="../index.html" />
</head>

B- Com III – Web Programming


12 Apoorva Publishers

7. What are Text (Character) formatting tags in HTML? (Or) What are Physical Tags in
HTML?

Formatting tags: Formatting tags are used to apply formatting to the text. They render
the text in different formats according to the tag used. The common formatting tags
are listed below. The listed tags are known as physical tags. Physical tags define how
the text should be displayed in the browser. They control the Physical characteristics of
the text.

Tag Description
<b> Defines bold text
<i> Defines italic text
<u> Defines underlined text
<big> Defines big text
<small> Defines small text
<sub> Defines subscripted text
<sup> Defines superscripted text
<tt> Defines teletype text
<strike> Strikes off the text
<blink> Makes the text blinking
<font> Allows us to set font-face, color and size
<center> Aligns the text in center

Example:
<html>
<body> Output:
<B>Hello </B> <BR>
<I> Hello </I> <BR>
<U> Hello </U> <BR>
H<sub>2</sub>O <BR>
x<sup>2</sup>y <BR>
<TT>Hello<TT> <BR>
<strike>Hello</strike>
<BR>
<blink>Hello</blink> <BR>
<font face="arial"> Hello
</font>
<center>Hello</Center>
<BR>
</body>
</html>

B- Com III - Web Programming


Apoorva Publishers 13
8. Write about Paragraph Formatting tags.

Paragraph Formatting Text: The following tags are used to format a paragraph. When
used, they create new paragraphs by introducing new line to the text written in them.

Tag Description
<div> It defines a division in the document
<p > It defines a paragraph
<pre> Preformatted text, it writes text exactly as it is,
including spaces.
<br> forces the browser to start a new line
<blockquote> Blockquote produces text that is indented in from both
the left and right margins.
<address> This tag is used to enclose information such as
"address, signature and authorship"
<center> Center aligns the text/paragraph
<xmp> Similar to preformatting tag; it also ignores the html
code with in this tag.
<h1>, <h2>,..<h6> Generates headings in different sizes

Example: Output:
<html> New Section
<body>
<div> New Section </div>
<p> I am a paragraph </p> I am a paragraph
<pre>too many spaces</pre>
<blockquote> Note this too many spaces
point</blockquote> Note this point
<address> Ravi, 7/G, Brindavan Ravi, 7/G, Brindavan Colony
Colony </address>
<br> Text in the Next Line
<center> Centered Text</center> Text in the Next Line
<xmp>Even tags as they are: Centered Text
e.g.<h1>hi</h1> </xmp> Even tags as they are:
</body> e.g.<h1>hi</h1>
</html>

9. Explain different Formatting tags in HTML?

Note: Refer to previous two questions.

B- Com III – Web Programming


14 Apoorva Publishers

10. What are Logical Tags in HTML? Explain.

Logical Tags: Logical tag tells how the text is being used. They indicate the 'type' of
content they enclose. They do not determine the display of the text and the browser is
free to determine its display style. There are tags for emphasizing important sections of
text, for definitions and citations, computer output and other data.

Tag Description
<strong> Defines strong text
<em> Defines emphasized text
<ins> Defines inserted text
<del> Defines deleted text
<code> Defines computer code text
<kbd> Defines keyboard text
<samp> Defines sample computer code
<var> Defines a variable
<abbr> Defines an abbreviation
<acronym> Defines an acronym
<bdo> Defines the text direction
<address> Defines an address element. This tag is used to enclose
information such as "address, signature and authorship"
<blockquote> Defines a long quotation. Blockquote produces text that is
indented from both the left and right margins.
<q> Defines a short quotation
<cite> Defines a citation
<dfn> Defines a definition term
<mark> Intended to be highlighted

Example: Following lines of code uses some of the above tags. Output is shown.

B- Com III - Web Programming


Apoorva Publishers 15
<html>
<body>
<strong> I am Strong </strong>
<br><em> Emphasized </em>
<br><ins> Text to insert </ins>
<br><del> Deleted Text </del>
<br>
<CODE>for (i=0; i<10; i++) <br>
{printf("%d",i);}</CODE>
<br>Enter <KBD>Q</KBD> to quit
<br><SAMP>Count = 1 </SAMP>
<br><VAR>Percent</VAR>
<br><abbr> XL- Xtra Large </abbr>
<br><acronym> WE - Well Educated
</acronym>
<address> 7/g, Abc Colony </address>
<bdo> Welcome </bdo>
<blockquote> WELCOME </blockquote>
<q> Short Quote </q>
<CITE> HTML is simple </CITE>
<br><DFN> IP is Internet Protocol
</DFN>
</body>
</html>

11. Distinguish between Physical HTML style tags and Logical HTML style tags.
(Or) Distinguish between Dependent Tags and Independent Tags with two
examples for each tag.

Physical Tags:
 Physical tags define how the text should be displayed in the browser.
 They control the Physical characteristics of the text.
 They are browser independent and hence known as independent tags.
 That is, they are rendered same in different browsers.
 Some of the physical tags are: <B>, <I>, <U>, <SUP>, <SUB> and so on.

Logical Tags:
 Logical tags indicate the 'type' of content they enclose.
 They do not determine the display of the text and the browser is free to determine
its display.
 They are browser dependent and hence known as dependent tags.
 That is, they may be rendered differently in different browsers.
 Some of the logical tags are: <EM>, <STRONG>, <ADDRESS>, <CODE>, <SITE> and
so on.

B- Com III – Web Programming


16 Apoorva Publishers
Note: Also, refer to Q.No 7 and 10 in this chapter

12. Write about different Heading tags.

Heading Tags: Headings are most common type of inclusion in any writing. It can be
used to divide the page into sections. In HTML there are six types of heading tags. <H1>
to <H6>. When we use headings, they automatically appear in new lines. The following
program uses different heading tags.

<html> Output:
<body>
<h1>Hello </h1>
<h2>Hello </h2>
<h3>Hello </h3>
<h4>Hello </h4>
<h5>Hello </h5>
<h6>Hello </h6>
</body>

13. How do you write Comments in HTML documents?

Giving comments is something like providing internal documentation. It is very useful


to include comments, inside the HTML files.

The comment tag is an empty tag in which the comment is placed. The beginning of the
tag is "<!--" and the end of the tag is "-->". Any tags placed within the comment are
ignored by the browsers.
Syntax:
<!-- text -->
Example:
<BODY>
<!-- My First Greetings -->
<H1> Hello </H1>
</BODY>

B- Com III - Web Programming


Apoorva Publishers 17
14. Write short notes on <FONT> tag.

Font Tag: The font tag is used to control the formatting of the text on the web page. It
has several useful attributes:
 Color: color specifies the font color. We can specify the color name or the hexadecimal color
code.
 Size: size is a number from 1 to 7 that defines the size of the text, with 1 being the smallest.
The standard text size is 3.
 Face: face is a text string that defines the font face which takes the values such as
"verdana", "times new roman", "arial", etc.

Example: If we want to display some text in blue color using large font size and in the
Verdana font, we use the following HTML code:
<font face="verdana" size="6" color="blue">
Hi Apoorva
</font>

We can also embed one font tag in the other (it display ‘APOORVA’ in red color and the
rest in blue color):
<font face="Arial" color="blue"> I am a Student of
<font color="red"> APOORVA </font> College </font>

15. Write short notes on <MARQUEE> tag And Explain its Attributes. (Or) How to create
scrolling text/images in HTML?

Creating Scrolling Text: The <MARQUEE> tag is used to create a scrolling text or image.
A marquee can be made to scroll from left to right or right to left. Attributes of the
<MARQUEE> tag are:

 Bgcolor: Used to specify the background color of a marquee in hexadecimal


format.
 Direction: Used to specify the direction of the scrolling action as either "LEFT" or
"RIGHT".
 Align: Used to specify whether the marquee text is aligned to the TOP, MIDDLE or
BOTTOM of the marquee.
 Height: Used to specify the height of the marquee in either pixels or a percentage
of the page.
 Width: Used to specify the width of the marquee in either pixels or a percentage of
the page.
 Loop: Used to specify the number of times a marquee scrolls in either number of
scrolls (LOOP=2) or infinitely with the LOOP=INFINITE setting.

B- Com III – Web Programming


18 Apoorva Publishers
 Vspace and Hspace: Used to specify the amount of clear space adjoining a
marquee in pixels.
 Scrolldelay: Used to specify the time between scrolls in milliseconds.
 Scrollamount: Used to specify the horizontal space
 Behavior: Specifies scrolling style: scroll, slide and alternate.

Example: The following code scrolls the text from right to left.
<html>
<marquee bgcolor=yellow> WELCOME TO APOORVA </marquee>
</html>

16. Write short notes on <IMG> (Image) tag. (Or) How to add images to HTML pages?

<IMG> Tag: We use the Image tag to place images in web pages. The Image tag has no
closing tag. But, it has one required attribute (src), along with few other attributes.

 Src: identifies the URL of the image and must be enclosed in quotes. This is a
required attribute.
 Alt: provides alternative text in case the image doesn't load. The alt text also
appears if the user moves the mouse cursor over the image for a few seconds.
 Width, height: They specify the width and height of the image. If we only specify
one of these, the image will maintain it's aspect ratio, so we generally need to
indicate one or the other. The number specified can represent the size in pixels or
a percentage of the original width and/or height.
 Align: specifies how the image should be aligned with respect to surrounding text.
The options are top, middle, bottom, left and right.
 Vspace, Hspace: Specifies right and left side spacing in the case of hspace and top
and bottom spacing in the case of vspace.
 Border: Specifies border width around the image.
 Usemap: Specifies an image as client side image map.

Example: The following code displays an image.


<img src=”www.smartclass.co/images/logo.jpg” alt="My Logo">

To make the image 200 x 100 pixels in size, we use the following code.
<img src="www.smartclass.co/images/logo.jpg" alt="My Logo"
width="200" height="100">

17. How do you place objects or multimedia content in HTML pages? (Or) How do you play
Audio and Video files in HTML?

B- Com III - Web Programming


Apoorva Publishers 19
To embed multimedia content or to include objects such as images, audio, videos, Java
applets, ActiveX, PDF, and Flash, we use <object> and <embed> tags.

a) Object Tag: The object tag tells browser to include a multimedia application. The
browser retrieves the file specified in the DATA attribute. Other attributes are class id,
code type, hspace and etc.
Example: <object data=“abc.wrl” height=“200” width=“200”>
</object>

b) Embed tag: The embed-tag is similar to the object tag in that it allows us to include
multimedia in an HTML document.
Example: <embed src=“pokiri.mid” height=“200” width=“200”>

HTML 5.0 added two new tags <AUDIO> and <VIDEO> to play audio and video files.

18. Explain Graphics of HTML with the help of an example.

Graphics can be easily added to html pages using tags like <marquee>, <img>, <object>
and <embed> tags. That is, using these tags we can create the following.
1. Scrolling Text/Images
2. Adding images
3. Adding Multimedia objects or Audio/Video Content.

1. Creating Scrolling Text: The <MARQUEE> tag is used to create a scrolling text or
image. A marquee can be made to scroll from left to right or right to left.
Attributes of the <MARQUEE> tag are: align, direction, bgcolor, height, width and
etc.
Example: The following code scrolls the text from right to left.
<html>
<marquee bgcolor=yellow> WELCOME TO APOORVA </marquee>
</html>

2. Adding Images: We can add images using <IMG> tag of html. We can easily control
it’s alignment, height and width using its attributes. The Image tag has no closing
tag. But, it has one required attribute (src), along with few other attributes like
height, width, alt, align, hspace, vspace and so on.
Example: The following code displays an image.
<img src="logo.jpg" alt="My Logo" width="200"
height="100">

3. Adding Multimedia objects and Audio/Video content:

B- Com III – Web Programming


20 Apoorva Publishers
Note: Refer to Question No.: 17 in this chapter

19. Explain ALIGN attribute in images. (Or) How do you align Images with respect to text?

We use the Image tag to place images in web pages. The Image tag has no closing tag.
But, it has one mandatory attribute (src), along with few other attributes. One of the
important attribute is ‘align’, which is used to specify how the image should be aligned
with respect to surrounding text. The options are top, middle, bottom, left and right.

Example: The following code displays images with left and right alignment options. The
output is also shown.

<img src="apoorva.gif" align=left width=80 hieght=80>


This is an Image-text demo where Image is aligned at left
<BR> Students of APOORVA college rock
<BR>
<img src="apoorva.gif" align=right width=80 hieght=80>
This is an Image-text demo where Image is aligned at right
<BR> Students of APOORVA college are Leaders
Output:

20. What is Image Mapping? (Or) Write short notes on <MAP> and <AREA >tags.

Image mapping allows us to create clickable regions on a single image. These clickable
regions act like hyperlinks which on clicking open other documents or take us to other
locations. These are also known as hotspots. For this, we use <AREA> and <MAP> tags.
To create hotspots i.e. image mapping we follow the three steps listed below:

1. Create an image and set value (name of a map) to the attribute ‘usemap’.
2. Create the map identified by the name used in ‘usemap’. This includes <area>
tags to create clickable regions.
3. Create the clickable regions (rect or circle or polygon) by specifying
coordinates.

B- Com III - Web Programming


Apoorva Publishers 21
<AREA> tag: The <AREA> tag is used to divide a page in to some parts by means of
various shapes. This tag will take three attributes. The COORDS attribute gives the
value of the coordinates. The SHAPE attribute specifies the Shape of the area. Within
the area we can specify the HREF attribute. The total code under the <AREA> tag
should be enclosed within the <MAP> tag.

Example: The following program creates three hotspots (clickable regions) on the
image “planets.gif” using <IMG>, <MAP> and <AREA> tags.

<html>
<body>
<p>Click on the sun or on one of the planets </p>
<img src="planets.gif" width="145" height="126"
alt="Planets" usemap="#planetmap" />
<map name="planetmap">
<area shape="rect" coords="0,0,82,126" alt="Sun"
href="sun.html" />
<area shape="circle" coords="90,58,3" alt="Mercury"
href="mercury.html" />
<area shape="circle" coords="124,58,8" alt="Venus"
href="venus.html" />
</map>
</body>
</html>

Output:

21. Write about different types of Lists in HTML.

HTML allows mainly three types of lists. They can be used for giving numbers and
bullets to the lists. We can also nest the lists. The three types are:
1. Ordered List (OL)
B- Com III – Web Programming
22 Apoorva Publishers
2. Unordered List (UL)
3. Definition List (DL)

1. Ordered List: This gives numbering to the list items. The numbering could be
Arabic numerals or roman numeral or alphabets depending on the value of the
‘type’ attribute of ordered list. The tag used is ‘<OL>’. The different values of ‘type’
can be:

Type Description
1 The default. Uses Arabic numerals.
I Uses uppercase Roman numerals.
i Uses lowercase Roman numerals.
A Uses uppercase letters.
a Uses lowercase letters.

<html>
<body> Output:
<h1>Select a Fruit </h1>
<OL>
<LI> APPLE </LI>
<LI> MANGO </LI>
<LI> BANANA </LI>
</OL>
</body>
</html>

If we change the ‘type’ value to ‘I’ i.e. to get roman numerals, it is going to be like
this.

<ol type="I"> Output:


<li> Cats </li>
<li> Dogs </li> I. Cats
</ol> II. Dogs

2. Unordered List: This gives bullets to the list items. The bullets could be square
type, circle type depending on the value of the ‘type’ attribute of ordered list. The
tag used is ‘<UL>’. The different values of ‘type’ can be:

Type Description
disc The default. Uses a filled circle.
circle Uses a hollow circle.
square Uses a filled square.

B- Com III - Web Programming


Apoorva Publishers 23

<html> Output:
<body>
<h1>Select a Fruit </h1>
<UL>
<LI> Apple </LI>
<LI> Mango </LI>
<LI> Banana </LI>
</UL>
</body>
</html>

3. Definition List: A kind of listing in which the definition term using <DT> and its
description using <DD> can be taken. The following list demonstrates the definition
list. The tag used for definition list is ‘<DL>’.
<html> Output:
<body>
<h1> ONLINE TUTORIAL</H1>
<DL>
<DT> HTML </DT>
<DD> Hyper Text Markup
Language </DD>
<DT> WWW</DT>
<DD> World Wide Web</DD>
<DT> CGI </DT>
<DD> Common Gateway
Interface</DD>
</DL>
</body>
</html>

22. Write about <TABLE> tag. (Or) How do you create tables in HTML?

<TABLE> tag: To produce tables in html, we use <table> tag. The entire table element is
delimited by the <TABLE> and </TABLE> tags. It requires additional tags such as <th>,
<tr> and <td>, which are explained below.

<TR>: This tag is used to define a Table Row. Each table row is delimited by the <TR>
and </TR> tags. Table rows are nested within the table element described above.

<TD>: This tag is used to define Table Data i.e. value in each cell. Each cell (or table
data) is delimited by the <TD> and </TD> tags. The cells are nested within the table row
element.

B- Com III – Web Programming


24 Apoorva Publishers
<TH>: This tag produces a row, which is normally used has header row. Each table
header is delimited by the <TH> and </TH> tags. Most browsers display the content of
a table header cell in boldface.

Example:
<html>
<html>
<body>
<h1> Marks Memo </H1>
<table bgcolor=yellow border=1
width=200>
<tr>
<th> Name </th> <th> Rno </th>
<th> Marks </th>
</tr>
<tr> Output:
<td> Ravi </td>
<td> 500 </td>
<td> 33 </td> Marks Memo
</tr> Name Rno Marks
<tr>
<td> Kiran </td> <td> 44 </td>
<td> 600 </td> Ravi 33 500
</tr>
<tr>
<td> Raju </td> <td> 55 </td> Kiran 44 600
<td> 700 </td>
</tr>
</table> Raju 55 700
</body>
</html>

The commonly used table attributes are listed below.

Attribute Description
align Specifies the alignment of a table according to surrounding
text. Values can be: left, center, right
bgcolor Specifies the background color for a table
border Specifies the width of the borders around a table
cellpadding Specifies the space between the cell wall and the cell content
cellspacing Specifies the space between cells
width Specifies the width of a table

23. Using table and its sub-tags Design a Students Marks Memorandum

Note: Refer to the previous question.

24. Using table and its sub-tags create the following table.
B- Com III - Web Programming
Apoorva Publishers 25
Horses Race Time
Blueball Fortbell 5.25
Blue Prince Fortbell 6.5

To create the above table, we use <TABLE> tag and the sub-tags of <TABLE> tag <TR>,
<TD> and <TH>.

<TABLE> tag: To produce tables in html, we use <table> tag. The entire table element is
delimited by the <TABLE> and </TABLE> tags.
<TR>: This tag is used to define a Table Row. Our sample table has four horizontal rows.
Each table row is delimited by the <TR> and </TR> tags. Table rows are nested within
the table element.

<TD>: This tag is used to define Table Data i.e. value in each cell. Each cell (or table
data) is delimited by the <TD> and </TD> tags. The cells are nested within the table row
element.

<TH>: This tag produces a row, which is normally used has header row. Each table
header is delimited by the <TH> and </TH> tags. Most browsers display the content of
a table header cell in boldface.

HTML Code to create the given table:


<html>
<body>
<h1> Table Demo </H1>
<table border=1 width=200>
<tr>
<th> Horses </th>
<th> Race </th>
<th> Time </th>
</tr>
<tr>
<td> Blueball </td>
<td> Fortbell </td>
<td> 5.25 </td>
</tr>
<tr>
<td> Blue prince </td>
<td> Fortbell </td>
<td> 6.5 </td>
</tr>
</table>
</body>
</html>

B- Com III – Web Programming


26 Apoorva Publishers

25. Explain the table alignment attributes and cell alignment attributes. (Or) Explain
horizontal and vertical alignment in Tables with an example.

In a table, the content of each cell can align horizontally and vertically using different
options. The ‘align’ attribute of table specifies the alignment of table itself according to
surrounding text. But, the ‘align’ attribute of <td> aligns the text within the cell.
That is, to align text with the cells we make use of two tags: 1. Align and 2. Valign

1. Align: This aligns the text horizontally in the cell, the possible values for this
attribute are:

Value Description
left Left-align content (default for td elements)
right Right-align content
center Center-align content
justify Stretches the lines so that each line has equal width

Example: The following table uses ‘align’ attribute with different values.

<table border="1" height=200> Output:


<tr>
<th>Month</th>
Month Sales
<th>Sales</th>
</tr> January 10000
<tr>
February 20000
<td align="left">January</td>
<td align="right">10000</td>
</tr>
<tr>
<td valign="center">February</td>
<td valign="justify">20000</td>
</tr>
</table>

2. Valign: This aligns the text vertically in the cell, the possible values for this
attribute are:

Value Description
Top Top-align content
middle Center-align content
bottom Bottom-align content
baseline Alignment as per the baseline

B- Com III - Web Programming


Apoorva Publishers 27
Example: The following table uses ‘valign’ attribute with different values.
<table border="1" height=200>
<tr>
<th>Month</th>
Month Sales
<th>Sales</th>
</tr> January
<tr> 10000
<td valign="top">January</td>
<td valign="middle">10000</td>
</tr>
<tr>
<td valign="baseline">February</td> February 20000
<td valign="bottom">20000</td>
</tr>
</table>

26. Write about Column spanning and Row spanning in tables with an example. (Or) Explain
Spanning columns and Rows in a table with the help of an example.

In HTML, a table can have rows and columns evenly or sometimes a cell can span in
multiple columns or in multiple rows. To achieve this, we use colspan, rowspan
attributes of <TD> tag. Consider the following examples.

 Spanning Column: The following code displays a table that has a cell
which spans in two columns. For this, we used colspan=2 for the cell of the
first row.
Output:
<table border=1 width=300>
<tr> <td colspan=2> APOORVA APOORVA
</td> </tr>
<tr> <td> Degree College </td>
<td> MBA College </td> </tr> Degree College MBA College
</table>

 Spanning Row: The following code displays a table that has a cell, which
spans in two rows. For this, we used rowspan=2 for the first cell of first row.
<table border=1 width=300> Output:
<tr> <td rowspan=2> APOORVA Degree College
</td> <td> Degree College
</td></tr> APOORVA
<tr> <td> MBA College </td> MBA College
</tr>
</table>

B- Com III – Web Programming


28 Apoorva Publishers

27. Explain how to create a table and design the Border, Horizontal, Vertical
alignment, Spanning columns and Rows in a table with the help of an example.

Note: Refer to previous two Questions.

28. How do you create links in HTML? (Or) Write about <A HREF> tag.

A link or hyperlink is some highlighted text which on clicking takes to other page, or
other website or another location in the same page. Hyperlinks facilitate non-linear
reading. HTML allows us to create hyperlinks using anchor tag. Anchor tag has one
mandatory attribute ‘href’ which specifies the target page or location. The text that
acts like hyperlink should be delimited by <a> and </a>. An anchor can point to any
resource on the Web: an HTML page, an image, a sound file, a movie, etc.

The syntax of creating an anchor (link):


<a href="url"> Text to act as hyperlink </a>

Examples:
 The following link which on clicking takes to a website
<a href="www.winningbrains.com”> See More </a>
 The following link which on clicking takes to another page in the same website
<a href="../index2.html”> Learn More </a>
 The following link which on clicking takes to another location in the same page. For
this, we need to assign a name to the target location.
<a href="#advantages"> See advantages </a>
………
<a name=”advantages”> … </a> …
 The following link which on clicking opens an image
<a href=”logo.gif”> See The Logo </a>
 The following link which on clicking opens the page in a new window.
<a href="../index2.html” target=”_blank”> Do More </a>

29. What are the attributes used in Anchor (<a>) tag.

The commonly used attributes of the anchor tag are shown below.

Attribute Value Description


coords coordinates Specifies the coordinates of a link
href URL Specifies the destination of a link
hreflang language_code Specifies the language of a linked document
name section_name Specifies the name of an anchor

B- Com III - Web Programming


Apoorva Publishers 29
rel text Specifies the relationship between the current
document and the linked document
rev text Specifies the relationship between the linked
document and the current document
shape default Specifies the shape of a link
rect
circle
poly
target _blank Specifies where to open the linked document
_parent
_self
_top
framename

Example: The following link which on clicking opens the page in a new window. This
uses ‘target’ attribute.
<a href="../index2.html” target=”_blank”> Learn It </a>

30. Write short notes on ‘target’ attribute of anchor tag. (Or) Explain how to open
documents trough hyperlinks in different ways (targets)

A link or hyperlink is some highlighted text which on clicking takes to other page, or
other website or another location in the same page. It uses an attribute called ‘target’,
which specifies where to open the linked document.

TARGET controls where the new document will be displayed when the user follows a
link. Most of the time, clicking on a link simply loads a new document in the same
window where the link is. However, with TARGET, we can have the new document
open in a new window, or in another frame or in the same or parent window.

TARGET can have the following values.


 "_blank"
 "_parent"
 "_self"
 "_top"
 “framename”

Example: The following link, which on clicking opens the page in a new window. This
uses ‘target’ attribute.
<a href="../index2.html” target=”_blank”> Learn It </a>

B- Com III – Web Programming


30 Apoorva Publishers

31. How do you make an image as a hyperlink? (Or) How to create Graphical
Hyperlinks in HTML? Give an example.

Not only text can be made as a hyperlink, but also images can be made as hyperlinks.
Thus, when clicking on the given image, it opens the linked document or takes to a
book-marked location. This is something like creating graphical hyperlink.
This can be achieved with the same anchor tag <a>. Between the pair of an anchor
tag, we use <img> tag to make an image as hyperlink. This technique can be used to
display thumb nails which on clicking open the enlarged images or to represent
companies/sites by some images or by their logos, which is much effective than
displaying text.

Example:
 The following codes display two image, which on clicking takes to the linked
websites.
<a href="www.winningbrains.com”>
<img src=”brain.jpg”>
</a>
<a href="www.wikipedia.com”>
<img src=”wikilogo.jpg”>
</a>

32. Write about Background animations in HTML pages. (Or) Write about background
images and sounds.

Background Animations: To a small extent, HTML allows creating background


animations. That is, by giving background color, or by setting a background image or by
playing background audio/video.

 Background color: The BGCOLOR attribute of <BODY> tag establishes the


background color of the page. We can either use text based color names such as

B- Com III - Web Programming


Apoorva Publishers 31
RED, GREEN, or BLUE or we can specify colors as a hexadecimal] numbers.
Example: <BODY BGCOLOR="RED">

 Background images: BACKGROUND is an attribute of the <BODY> tag. The


BACKGROUND attribute allows the HTML browser to specify a graphics file to be
tiled in the background of the page. The image file formats allowed are: jpg, gif,
png, bmp.
Example: <BODY BACKGROUND="logo.jpg">

 Background Music: Background sound can be added using the tags <bgsound>.
The two main attributes it takes are ‘src’ and ‘loop’. The loop attributes determines
the number of times the audio file is played.
Example: <BGSOUND SRC="MySong.wav" LOOP=INFINITE >

33. What are Form Elements (Components)? Explain. (Or) Explain <FORM> tag in detail.
Forms: Forms are the most popular way to make web pages interactive. Like forms on
paper, a form on a web page allows the user to enter requested information and
submit it for processing.

<FORM> tag: The <form> tag is used to create an HTML form for user input. A form can
contain input elements like text fields, checkboxes, radio-buttons, submit buttons and
more. A form can also contain select menus, textarea, and label elements. Forms are
used to pass data to a server.

Form Elements Description


Text A control that allows single line text
Password A control that allows the user to enter passwords
TextArea A control that allows multi- line text
Button An element that represents a button. The user presses or clicks to initiate an
action.
Submit Button Submit button sends values of form elements to a server.
Reset Button Reset button clears the information types in form elements.
Checkbox It is a control that provides the user with a toggle choice (checked or
unchecked).
Radio A "radio button" used in groups, where only one option at a time can be
selected.
File This displays a text box along with a “browse” that allows us to select files
from local computer. The selected file appears in the text box.
select This is an element used to create a list of items (similar to list boxes and
combo boxes)
B- Com III – Web Programming
32 Apoorva Publishers
<FORM> tag Attributes: The commonly used <form> tag attributes are listed below.

Attribute Value Description


action URL Specifies where to send the form-data when a form is
submitted
accept MIME_type Specifies the types of files that can be submitted through a
file upload
accept- charset Specifies the character-sets the server can handle for form-
charset data
method get Specifies how to send form-data
post
name name Specifies the name for a form

34. Explain How to Create Different form elements with code.

Example: The following code displays text and Output:


password controls.

<FORM>
name: <INPUT TYPE=TEXT NAME=pname> <BR> name:
password: <INPUT TYPE=PASSWORD
NAME=email> <BR> password:
<INPUT TYPE=SUBMIT>
</FORM> Submit Query

Example: The following code displays textarea control. Output:


please enter your commen
<textarea cols="25" name="comments"
rows="6">please enter your
comments...
</textarea>

B- Com III - Web Programming


Apoorva Publishers 33
Example: The following code displays button, submit Output:
and reset controls.
<input type=button value="OK"> <br>
<input type=submit > <br>
<input type=reset > <br>

Example: The following code displays checkbox Output:


control.
<input type="checkbox" value="Apple">
Apple<br> Apple
<input type="checkbox" value="Banana"
>Banana<br> Banana
<input type="checkbox" value="Mango"
checked >Mango<br> Mango

Example: The following code displays radiobutton Output:


control.
<input type="radio" value="Low" >
Apple<br> Low
<input type="radio" value="High" >
Banana<br> High
<input type="radio" value="Medium"
checked> Mango<br> Medium

Example: The following code displays file control. Output:


<h2> Upload Your Files </h2>
<input type="file">

Example: The following code displays seelct control. Output:


<select name="Fruits">
<option>Apple</option>
<option>Banana</option>
<option>Mango</option>
<option selected>Cherry</option>
</select>

35. Explain <INPUT> tag in detail.

B- Com III – Web Programming


34 Apoorva Publishers
<INPUT> tag: The <input> tag is used to select user information. An input field can vary
in many ways, depending on the type attribute. An input field can be a text field, a
checkbox, a password field, a radio button, a button, and more.

This tag takes two main attributes: TYPE and NAME. TYPE indicates what kind of
element should appear on the form. NAME assigns a name to go with the input field.
The ‘type’ attribute can take any of the following values.
 Text: Provides a single line text box.
 Textarea: Provides a multiline text box.
 Password: Same as the TEXT type, but characters are displayed as asterisks.
 Button: Creates a button with which a user can initiate some action.
 Submit: Creates a button labeled "submit". This on clicking sends information from
form-elements to a server.
 Reset: Creates a button labeled "reset" in the form. Using this, a user can clear the
values of the form elements.
 Checkbox: Produces an on-screen check box for users to make multiple choices
 Radio: Creates a radio button for a range of selections from which the user may
select only one.
 File: This displays a text box along with a “browse” that allows us to select files
from local computer. The selected file appears in the text box.

Other INPUT attributes:


 ALIGN: This is for image elements, determines how the graphic is aligned on the
form. Values can be TOP | MIDDLE | BOTTOM | LEFT | RIGHT.
 CHECKED: It specifies what item should be selected by default in the case of
checkboxes and radio buttons.
 SIZE: This is used to set the number of characters that a text element can display
without scrolling.
 TABINDEX: It is a "number" specifying the element position in the tabbing order,
i.e. the transition order from field-to-field.
 VALUE: The "value" supplies the corresponding value for a radio button or check
when they are selected.

Example: The following code displays text and Output:


password controls.

<FORM>
name: <INPUT TYPE=TEXT NAME=pname> <BR> name:
password: <INPUT TYPE=PASSWORD
NAME=email> <BR> password:
<INPUT TYPE=SUBMIT>
</FORM> Submit Query

B- Com III - Web Programming


Apoorva Publishers 35
36. Write short notes on <LEGEND> and <FIELDSET> tags.

<LEGEND> is used with <FIELDSET> to give a title to each set of fields. This is very useful
to show the separation of groups with a border and title and it is more visually
appealing.
 The <fieldset> tag is used to logically group together elements in a form.
 The <fieldset> tag draws a box around the related form elements.
 The <legend> tag defines a caption for the fieldset element.

Example: Output:
<FIELDSET>
<LEGEND> Personal Details
</LEGEND>
<BR>
name: <INPUT NAME="pname">
<BR>
email: <INPUT NAME="email">
</FIELDSET>

37. Write short notes on <FRAME> tag. (Or) Explain Frames in HTML? (Or) What is a
Frameset? Explain how to create Horizontal and Vertical Frames.

In HTML, frames enable us to present multiple HTML documents within the same
window. For example, we can have a left frame for navigation and a right frame for the
main content.

Frames are achieved by creating a frameset page, and defining each frame from within
that page. This frameset page doesn't actually contain any content - just a reference to
each frame. The HTML <frame> tag is used to specify each frame within the frameset.
All frame tags are nested with a frameset tag.

So, in other words, if we want to create a web page with 2 frames, we would need to
create 3 files - 2 files for two frames, and 1 file to specify how they fit together.

The frameset Tag Attributes: In the frameset tag, we specify either cols or rows,
depending on whether we want frames to be displayed vertically or horizontally. The
common attributes in <frameset> tag are:

Attribute Description
rows Specifies the number of rows and their height in pixels, percentages,
or relative lengths. Default is 100%

B- Com III – Web Programming


36 Apoorva Publishers
cols Specifies the number of columns and their width in either pixels,
percentages, or relative lengths. Default is 100%

The frame Tag Attributes: For each frame we want to display, we specify a frame tag.
We nest these within the frameset tag. The common attributes in <frame> tag are:

Attribute Description
name Assigns a name to a frame. This is useful for loading contents
into one frame from another.
src Location of the frame contents (for example, the HTML page to
be loaded into the frame).
noresize Specifies whether the frame is resizable or not (i.e. whether the
user can resize the frame or not).
scrolling Whether the frame should be scrollable or not (i.e. should
scrollbars appear). Possible values are : yes, no, auto
frameborder Whether the frame should have a border or not. Possible values
are : 0 or 1
marginwidth Specifies the margin, in pixels, between the frame's contents
and it's left and right margins.
marginheight Specifies the margin, in pixels, between the frame's contents
and it's top and bottom margins.

Example: Following program uses three vertical frames. Before writing this, the user
needs to create three HTML files to be displayed in each frame. Here, ‘a1.html’,
‘a2.html’ and ‘a3.html’.

<html> Output:
<frameset cols="25%,50%,25%">
<frame src='a1.html'>
<frame src='a2.html'>
<frame src='a3.html'>
</frameset>
</html>

Similarly, to create horizontal frames we use the following code.

<html>
<frameset
rows="50%,30%,20%">
<frame src='a1.html'>

B- Com III - Web Programming


Apoorva Publishers 37
<frame src='a2.html'>
<frame src='a3.html'>
</frameset>
</html>

38. What are nested Frames?

A nested frame is a frame within another frame. Here, we need to use one frameset in
another frameset. The second frameset comprising two or more other frames takes the
position of second frame in the outer frameset.

Example: Following program uses nested frames. The outer frameset uses horizontal
farming and the inner frameset uses vertical framing. Here, ‘a1.html’, ‘a2.html’ and
‘a3.html’ have to be created first.

Output:
<html>
<frameset rows="50%,50%">
<frame src='a1.html'>
<frameset cols="50%,50%">
<frame src='a2.html'>
<frame src='a3.html'>
</frameset>
</frameset>
</html>

39. Create the following Frameset.

College Name
College Logo Courses Offered
 B.SC.
 B.Com.
 B.A.

B- Com III – Web Programming


38 Apoorva Publishers
To create the given page, we use <frameset>, <frame> and <UL> tags. We need to
create four different HTML files 1) To display college name (college.html), 2) To display
college Logo (logo.html), 3) Course Details (course.html) and 4) A page with nested
frames (myframe.html). The programs are shown below. Finally, we need to view
“myframe.html” in a browser.

College.html
<html>
<body>
<center> <h4> College Name :</h4>
<h4> APOORVA DEGREE COLLEGE </h4> </center>
</body>
</html>

Logo.html
<html>
<body>
<center> <h4> College Logo:</h4>
<img src="apoorva.gif" width=100></center>
</body>
</html>
Course.html
<html>
<body>
<center> <h4> COURSES OFFERED </h4> </center>
<ul type=square>
<li> B.Sc. </li>
<li> B.Com. </li>
<li> B.A. </li>
</body>
</html>

MyFrame.html
<html>
<frameset rows="20%,*">
<frame src='college.html'>
<frameset cols="50%,*">
<frame src='logo.html'>
<frame src='course.html'>
</frameset>
</frameset>
</html>

Output:

B- Com III - Web Programming


Apoorva Publishers 39

40. Using tables and Frames Design the following web page:

College Name
Courses
Commerce Science
B.Com. (Eco.) B.Sc.
B.Com. (Computer) B.Sc. (Electronics)
B.Com. (Res.)
To create the given page, we use <frameset>, <frame> and <table> tags. We need to
create three different HTML files 1) To display college name (college.html), 2) Course
Details (course.html) and 3) A page with two horizontal frames (myframe.html). The
programs are shown below. Finally, we need to view “myframe.html” in a browser.
College.html
<html>
<body>
<CENTER> <h4> College Name :</h4>
<h4> APOORVA DEGREE COLLEGE </h4> </CENTER>
</body>
</html>
Course.html
<body>
<CENTER> <h4> COURSES </h4> </CENTER>
<table border=1 width=300>
<tr>
<th> Commerce </th>
<th> Science </th>
</tr>
<tr>
<td> B.Com (Eco.) </td>
<td> B.Sc. </td>
</tr>
<tr>
B- Com III – Web Programming
40 Apoorva Publishers
<td> B.Com (Computer) </td>
<td> B.Sc. (Electronics) </td>
</tr>
<tr>
<td> B.Com (Res.) </td>
<td> </td>
</tr>
</table>
</body>
</html>

MyFrame.html
<html>
<frameset rows="20%,*">
<frame src='college.html'>
<frame src='course.html'>
</frameset>
</html>
Output:

41. What are Inline Frames?

Inline or “floating” frame is the one, which appear on a page like an ordinary element
such as tables or images. Using an inline frame, we can display a html page within
some other html page. The tag used for inline frames is <iframe>. The attributes of this
tag are listed below.

 src: This allows us to specify the URL of the document in the frame.
 width: This allows us to specify the frame’s length, in pixels.
 height: This allows us to specify the frame’s height, in pixels.
 frameborder: This allows us to give the frame a border.
 Name: This is to set the name of the frame

B- Com III - Web Programming


Apoorva Publishers 41
Example: The following program uses an inline frame to display a previously created
html file “a1.html”.

Output:
<html>
<body bgcolor=green>
<center>
<h1> INLINE FRAMES </H1>
<iframe src='a1.html' frameborder=1>
</iframe>
</center>
</body>
</html>

42. Write the difference between a table and frame. Write a program to print the
different courses offered by an educational institutions using table.

Table: A table is a two dimensional representation of information i.e. it arranges


information in the form of rows and columns. A table in HTML page can be created
using <table> tag. The entire table element is delimited by the <TABLE> and </TABLE>
tags. It requires additional tags such as <th>, <tr> and <td>.

Frame: Frames enable us to present multiple HTML documents within the same
window. For example, we can have a left frame for navigation and a right frame for the
main content. Frames are achieved by creating a frameset page, and defining each
frame from within that page. This frameset page doesn't actually contain any content -
just a reference to each frame. The HTML <frame> tag is used to specify each frame
within the frameset. All frame tags are nested with a frameset tag.

Program: A program to print the different courses offered by an educational institute


using table - is shown below.

<body>
<center> <h4> COURSES </h4> </center>
<table border=1 width=350>
<tr>
<th> Commerce </th>
<th> Science </th>
</tr>
<tr>
<td> B.Com (Economics) </td>
<td> B.Sc. (Stats) </td>

B- Com III – Web Programming


42 Apoorva Publishers
</tr>
<tr>
<td> B.Com (Computers) </td>
<td> B.Sc. (Electronics) </td>
</tr>
<tr>
<td> B.Com (Company Secretary) </td>
<td> B.Sc. (Physics) </td>
</tr>
</table>
</body>
</html>

Output:

43. Explain the tags: <HR>, <SPACER>, <BANNER>, <LAYER>

<HR> tag: The <hr> tag creates a horizontal line in an HTML page. The hr element can
be used to separate content in an HTML page. It is an empty i.e. has no closing. The
common attributes of <HR> tag are listed below.

Attribute Value Description


align left, center, right Specifies the alignment of a hr element
noshade noshade Specifies that a hr element should render in
one solid color
size pixels Specifies the height of a hr element
width Pixels, % Specifies the width of a hr element

Example: <hr color=yellow width=300 height=20>

<SPACER> tag: The HTML <SPACER> tag is used to create a block of white space within
an html document. This is valid in Netscape browser. The common attributes
supported by this tag are:

B- Com III - Web Programming


Apoorva Publishers 43
Attribute Value Description
type Vertical,horizontal Specifies whether the spacer will be horizontal,
block vertical, or block.
size Number Specifies the height or width when it is
"horizontal" or "vertical" spacer.
width Number The width attribute is used when the spacer
type="block".
height Number The height attribute is used when the spacer
type="block". Specifies the height of the block.
align left, right, center Specifies the alignment of the block of white
space.

Example: Touch Me <spacer type="horizontal" width="50"> Not


Output: Touch Me Not

<BANNER> tag: Banner tag directs the browser to render the banner graphics/text
unmovable while the user scrolls the remainder of the content. The banner text is
delimited by the tags <banner> and </banner>. The Banner tag is the first tag after the
Body tag, before any text or other HTML coding. If the Banner Tag works, the image
and text should always be visible as we scroll down the page. The common attributes
supported by this tag are:

Attribute Value Description


align left, center, right, Specifies the alignment of a banner element
top, bottom
width Pixels, % Specifies the width of a banner element
Height Pixels, % Specifies the heigth of a banner element

Example: <banner width=500> ABC International Ltd. </banner>

<LAYER> tag: The HTML <layer> tag is used to position and animate (through scripting)
elements in a page. A layer can be thought of as a separate document that resides on
top of the main one, all existing within one window. This tag has support in Netscape
browsers. The common attributes supported by this tag are:

left/ top: The LEFT and TOP parameters specify the horizontal and
vertical positions of the top-left corner of the layer.
bgcolor Specifies the background color of the layer.
width/ height The width and height parameter determine the width and
height of the layer at which the layer's contents wrap.
visibility The VISIBILITY parameter determines whether the layer is
visible or not. Possible values are: HIDE, SHOW, INHERIT

B- Com III – Web Programming


44 Apoorva Publishers
src: The SRC attribute for the <LAYER> tag specifies an external file
that contains HTML-formatted text to be displayed in this layer.

Example: <layer width=100 height=30> <img src="myimage.gif">


</layer>

44. Explain the tags: <BODY>, <FONT>, <MARQUEE>, <BASEFONT> with minimum 2-3
attributes.

<BODY> tag:

Note: Refer to Q.No.5 In This Chapter

<Font> Tag:

Note: Refer to Q.No.14 In This Chapter

<MARQUEE> tag:

Note: Refer to Q.No.15 In This Chapter

<BASEFONT> tag: This tag specifies a default font-color, font-size, or font-family for all
the text in a document.

Attribute Value Description


Color some color Specifies the default color for text in a document
Face font_family Specifies the default font for text in a document
Size number Specifies the default size of text in a document

Example: <head> <basefont color="red" size="5"> </head>


<body> <h1> This is a header </h1> </body>

45. Explain the tags: <SMALL>, <HEAD>, <MARQUEE>, and <A HREF>.

<SMALL> Tag: Small tag renders the text in small size. This tag is supported in major
browsers. We can use nested <small> tags to produce even smaller size. It supports the
standard attributes but has no specific attributes.

Example: <small> Small Wonder </small> <br>


<small> <small> still cute </small> </small>

B- Com III - Web Programming


Apoorva Publishers 45
Output: Small Wonder
still cute

<HEAD> Tag:

Note: Refer to Q.No.6 In This Chapter


<MARQUEE> tag:

Note: Refer to Q.No. 15 In This Chapter

<A HREF> Tag:

Note: Refer to Q.No. 28 In This Chapter

46. Explain the tags: <EM>, <CODE>, <VAR>, <ABBR>, <ACRONYM>, and <KBD>.

The given tags are known as logical tags. Logical tag tells how the text is being used.
They indicate the 'type' of content they enclose. They do not determine the display of
the text and the browser is free to determine its display style.
All these tags support standard attributes but have so specific attributes. The
output of these tags may be different in different browsers.

 <EM> tag: This is used to emphasize the text.


Example: <EM> Hello Apoorva </EM>

 <CODE> tag: This defines computer code i.e. The code can be displayed as it is.
Example: <CODE> for (i=0; i<10; i++)
{printf("%d",i);}</CODE>
The above code will display: for (i=0; i<10; i++) {printf("%d",i);}

 <VAR> tag: This defines a variable. A browser can create its own display style for
all variables used in the page.
Example: <VAR> COUNT=1 </VAR> gives COUNT=1

 <ABBR> tag: This is used to define an abbreviation.


Example: <ABBR> HTML </ABBR>

 <ACRONYM> tag: This defines acronym.


Example: <ACRONYM> WE - Well Educated </ACRONYM>

 <KBD> tag: This indicates text to be entered by the user. This text is usually
rendered in a different font style where every character has the same width.
Example: Enter <KBD>Q</KBD> to quit

B- Com III – Web Programming


46 Apoorva Publishers
All the above tags support the following standard attributes:

Attribute Description
class Specifies a classname for an element
dir Specifies the text direction for the content in an element
id Specifies a unique id for an element
lang Specifies a language code for the content in an element
style Specifies an inline style for an element
title Specifies extra information about an element

47. Explain the tags: <MARQUEE>, <TABLE>, <BLINK>, and <MULTICOL>

<MARQUEE> tag:

Note: Refer to Q.No. 15 In This Chapter

<TABLE> tag:

Note: Refer to Q.No. 22 In This Chapter

<BLINK> tag: This tag makes the text blink. This is valid only in few browsers like
Netscape. Example is shown below. This has no specific attributes.

Example: <BLINK> HELLO APOORVA </BLINK>

<MULTICOL> tag: This tag is used to create multiple columns of text and lets us control
the size and number of the columns. The <multicol> tag can contain any other HTML
content. This tag is supported in Netscape. The common attributes supported by this
tag are:

Attribute Value Description


cols number Specifies the number of text columns for the text display.
gutter number Specifies the distance between each column in pixels.
width number Specifies the width of each column in pixels. All columns are of
the same width.

Example:
<multicol cols="4" gutter=”15” width=“50”>
Welcome To Apoorva
</multicol>

48. What are the main steps involved in creating a webpage and how does it get
executed? (Or) Explain the procedure to create HTML document.
B- Com III - Web Programming
Apoorva Publishers 47
The main steps involved in creating a web page or listed below.
1. Creating a web page using HTML or other web programming languages
2. Saving the file and previewing (executing) it in a browser
3. Publishing the web page

1. Creating a webpage: To create a web page, we can use simple text editors or GUI
editors like FrontPage or even MS-Word.
 If we are using an editor like note pad, we need to write the code using HTML
tags as per the requirement.
 If we are using FrontPage, we can place the required elements using drag and
drop methods or using menu options.

2. Saving the file and previewing (executing) in a Browser: When saving a HTML file,
we need to give the file extension as “.htm” or “.html”. To preview a HTML file, we
need to open a browser like Internet Explorer or Netscape navigator and type in
the file name in its location window and press enter key.

3. Publishing the webpage: Publishing becomes very easy using tools like Front Page.
This involves uploading the webpage to a hosting server and be able to access it
through www.

49. Explain the characteristics of Web Images in HTML?

Adding images to a HTML page is a common practice today. But, when adding images,
we need to understand the characteristics of images so that we can minimize their
loading time when they are accessed. The following are some important characteristics
of web images.

 Resolution: Web graphics are typically saved and displayed at a resolution of 72


pixels per inch (ppi), even though it is possible to save pictures at a much higher
resolution, because monitors have a fixed display resolution of 72 ppi. Higher-
resolution images require more storage space and take longer time to download
to the user’s computer.
 Color Depth: Though most computer screens can display colors of up to 24 or
even 32 bits, the files that take advantage of these color settings can be large.
Generally, Web designers use only two file formats -GIF and JPEG.
 Image Size: Although it is possible to save images that are larger than the user’s
display space, web designers avoid this practice. When a Web page requires
large graphics, designers try to ensure that the image is not very large or it is
broken into smaller images.
 Gamma: In computer imaging and display screens, gamma refers to the degree
of contrast between the midlevel gray values of an image. Gamma
B- Com III – Web Programming
48 Apoorva Publishers
considerations are particularly important when displaying images with very long
gray scales (such as fine black-and-white photography) or images in which the
exact color values are critical (such as works of art).
 Format: Commonly accepted image formats for web pages are: jpg, gif and png.

50. Discuss about good Web Design principles.

A web presentation is a collection of associated, hyper-linked web pages that usually


have some underlying theme. Web presentations are visually oriented and it must be
done effectively. Some of the key elements in a good web design are discussed below:

 Details: Good choices of background color, headers, footers, and appropriate font
size are all important details to be considered. Carefully prepared pages help to
enhance the credibility and readability of the presentation.
 Coding: A good programmer uses the appropriate elements of style to contribute
to the quality of the presentation. Simplistic pages could indicate lack of
knowledge and cluttered pages indicate poor design.
 Features: A few graphic and sound components can improve presentation. For
example, applets, or some Java scripts improve the quality. It is always better to
include too few fancy items.
 Graphics: Including graphics is the most significant ways to enhance our design.
Many free images can be found on the Web. It is important to integrate the images
effectively in to presentation.
 Layout: If the pages are visually appealing and if they provide convenient
navigation, they are likely to be visited by more users. A poor layout will
discourage people from spending too much time on the presentation.
 Writing Quality: Good writing and an interesting style are also necessary for a solid
presentation.
 Load time: Users should be taken care not to include too many graphics or any
large graphics. Also users should be given the option to downloading large images
separately.
 Hyperlinks: Navigation is a key element to any good Web presentation. If the
reader can move around the pages easily, they will be more impressed. It is always
a good idea to include much navigation.

51. What is the difference between a web page and ordinary file document?

Webpage Ordinary File Document


A web page can be accessed through An ordinary file document must be
www, user need not have a copy of it in present in a local computer to access it.
local computer

B- Com III - Web Programming


Apoorva Publishers 49
It displays text, photos, images, charts It also displays text, photos, images, charts
and etc and etc
Web pages often contain audio, video, Ordinary File documents rarely include
and other multimedia objects. these features.
It is created using different web This is created using word processors like
technologies like HTML, Script, ASP, JSP, note pad or word pad.
XML and etc
It may involve programming It does not involve any programming
It can be viewed in browsers It can be viewed in the same word
processor in which it was created.
This provides much navigation It has navigation but to a very less extent
This is designed to be displayed on This is designed to be printed on a paper
computer screens
Page sizes, image sizes and their There are no such restrictions here.
resolutions have limits
The code can be viewed and edited The code is not visible. The documents are
easily. directly and readily editable.
A web page is structured An ordinary file is not structured
The common web page file extensions The common ordinary file extensions are:
are: htm, html, php, asp, jsp txt, doc, docx, rtf and so on.
They allow user interaction. Facilitating user interaction is very rare.

52. Define WWW? (Or) What is Web?

WWW stands for World Wide Web. It is an Internet service developed to incorporate
footnotes, figures and cross-references into online hypertext documents. Hypertext
documents are those in which a user can jump to another location in the same
document or any other document by clicking on some highlighted text. WWW was
created in 1989 at Geneva, Switzerland.

53. Define a Webpage. Give an Example.

 Web page is page of any website that can be accessed through WWW.
 A web page can be designed using HTML, ASP, PHP, XML and etc.
 Web pages are basically hyper-linked documents that allow non linear reading
 Web pages can be dynamic, and they can involve multimedia.
 A web page can also be an interface to a database.

Example: The home page of ‘google.com’ is a webpage.

B- Com III – Web Programming


50 Apoorva Publishers

54. List common Image File Formats. (or) What are Image File Extensions

A file format is a standardized method of encoding data for storing data. Image files
have the following extensions:

File Format Meaning


BMP Bitmap Image
JPEG Joint Photographic experts group
PICT Picture
TIFF Tagged Image File Format
GIF Graphic Interchange Format
PNG Portable Network Graphics
ICO Icon

B- Com III - Web Programming


Apoorva Publishers 51

2 VBScript
1. What is VBScript? What are its Features, Advantages and Disdavantages?
2. What is a Data type? What are VBScript Data Types?
3. Distinguish between Client Side Programming and Server Side
Programming with examples.
4. How do you write a VBScript Program? How a VBScript program gets
executed?
5. What is Event Driven Programming?
6. What are Variables? How do you declare variables in VBScript?
7. Explain the Scope and Life of Variables. (Or) What are procedure-level and
Script-level Variables?
8. What are Constants? Explain Constants in VBScript.
9. Explain the Operators in VBScript.
10. Explain Control Structures in VBScript.
11. Explain Branching Control Structures in VBScript.
12. Explain Iterative Control Structures (Loops) in VBScript.
13. Explain Exit Statements in VBScript.
14. Explain With Statement (with/end with) in VBScript.
15. Explain various Functions in VBScript.
16. Explain Math (Number) Functions in VBScript.
17. Explain String (Text) Functions in VBScript.
18. Explain Date and Time Functions in VBScript.
19. Explain Conversion Functions in VBScript.
20. Explain Formatting Functions in VBScript.
21. Explain Logical Functions in VBScript.
22. Explain Miscellaneous Functions in VBScript.
23. Explain Array Functions in VBScript.
24. Write a program to demonstrate Date and Time Functions.
25. Write a program to demonstrate String Functions.
26. Explain String Manipulation Mechanism with an example in VBScript.
27. What are Arrays? How do you declare Arrays in VBScript? (Or) Explain Array
Handling in VBScript.
28. How do you write Comments in VBScript?

B- Com III – Web Programming


52 Apoorva Publishers
29. What are Procedures? Explain Sub-Procedures and Functions in VBScript?
30. Explain Sub-Procedures in VBScript?
31. Explain Functions in VBScript
32. Explain how do you write a Procedure with Arguments in VBScript?
33. What are VBScript Dialog Boxes? (Or) Explain Msgbox and Inputbox with
examples.
34. What are the different user interaction elements present in VB script? (Or)
How user interaction can be achieved in VBScript? (Or) What is User
Interaction? Write a program to show how it can be performed using
VBScript.
35. Write a program to display a message box while clicking on the button
using VB script.
36. Discuss about Dynamic Content with an example.
37. What are Run-Time Errors in VBScript? (Or) What are different types of
errors?
38. Explain Error Handling in VBScript.
39. What is Err Object? What are its Properties and Methods?
40. What is Data Validation (Form Validation)? Write a program to show how
data validation is performed using VB Script. (Or) Write notes on Data
Validation.
41. Write a program of Student Registration form using VB script. Write
necessary validations.
42. Using VBScript, Design a webpage of Student Registration form for a
Computer Institute.
43. Write a program in VB Script for adding any two numbers.
44. What are Scriptengines and how they are helpful? Explain.

B- Com III - Web Programming


Apoorva Publishers 53
1. What is VBScript? What are its Features, Advantages and Disdavantages?

VBScript (Visual Basic Scripting Edition) is an Active Scripting language developed by


Microsoft that is derived from Visual Basic. VBScript is web programming language that
can be embedded into an HTML web page for client side scripting or used in ASP for
server side scripting.

Features of VBScript:
 It is developed by Microsoft
 It is a loosely typed programming language. That is, data-type declaration is not
mandatory.
 VBScript programs are interpreted
 It is a light weight programming language
 It has only one data type called ‘variant’; all other sub data types are compatible
with this.
 It is derived from Visual Basic
 This is the default scripting language for ASP.
 It can be used for both client-side and server-side scripting.
 It can be used on IIS (Internet Information Server) to enhance the functionality of
server side applications.
 VBScript uses the Component Object Model
 VBScript is case-insensitive language

Advantages of VBScript
 No installation required. This is readily available with windows operating systems.
 Better support through MSDN
 VBScript can be directly embedded in HTML documents
 Built-in support for COM Automation and WSH (Windows Script Host)
 Simple to learn because it is derived from Visual Basic
 It allows event driven programming.
 It can be used for both client-side and server-side scripting.

Disadvantages of VBScript
 Limited third-party modules/add-ons
 No command-line code execution support
 Not supported by all the browsers

2. What is a Data type? What are VBScript Data Types?

B- Com III – Web Programming


54 Apoorva Publishers
Data-type: Data type tells what type of value a variable can hold. In VBScript, as it is a
loosely typed programming language, data type declaration is not mandatory. But, it is
a good programming practice to declare data types.

VBScript Data Types: VBScript has only one data type called a Variant. A Variant is a
special kind of data type that can contain different kinds of information, depending on
how it is used. Because Variant is the only data type in VBScript, it is also the data type
returned by all functions in VBScript. A Variant can contain either numeric or string
information. A Variant behaves as a number when we use it in a numeric context and
as a string when we use it in a string context.

Variant Subtypes: The different categories of information that can be contained in a


‘variant’ are called its subtypes. The following table shows subtypes of data that a
Variant can contain.

Subtype Description
Empty Variant is uninitialized. Value is 0 for numerals or a zero-length string
("") for strings
Null Variant intentionally contains no valid data
Boolean Contains either True or False
Byte Contains integer in the range 0 to 255
Integer Contains integer in the range -32,768 to 32,767
Currency Contains currency
Long Contains long integer
Single Contains a single-precision, floating-point number
Double Contains a double-precision, floating-point number
Date Contains a number that represents a date between January 1, 100 to
(Time) December 31, 9999
String Contains a variable-length string that can be up to approximately 2
billion characters in length.
Object Contains an object.
Error Contains an error number.

3. Distinguish between Client Side Programming and Server Side Programming with
examples.

1. Client-side programming: Client side programming is some code that runs in the
web browser on the user’s computer. An example of client-side programming is
JavaScript. Client-side code is embedded within the web page. By including code
within a web page, a number of features can be added to a web page without

B- Com III - Web Programming


Apoorva Publishers 55
sending information to the Web Server. VBScript, JavaScript, Jscript are the
languages used for client-side programming.

Advantages:
 HTML, JavaScript, Flash files, ActiveX controls, Java applets, and a number of
other technologies can be executed on the client side.
 They get executed faster.
 Client-side scripts have greater access to the information and functions
available on the user's browser.
 Client-side scripts do not require additional software on the server.
 They reduce burden on servers

Disadvantages:
 Client-side scripts may be restricted from executing by the operating system
or web browsers.
 A client-side script is plain text embedded in HTML documents. Anyone can
easily view the code.
 They require the support of web browsers without which they cannot
function.

Examples: Tasks done on the client side include the following.


 Data validations
 Special formatting features
 Page-navigations
 Ad presentation
 Displaying alerts
 Allowing users to play games and etc

Program: The following program is simple example for client side programming
that uses VBScript. It prints the given name when the button is clicked.

<script language="VBScript">
sub B1_OnClick()
document.write ("Hello " & frm.t1.value)
end sub
</script>
<form name="frm" >
Name: <input type="text" name="t1" > <BR>
<input type="button" value="OK" name="B1">
</form>
2. Server-side programming: Server-side programming is some code that runs on the
web-server where the website is located. The resulting code is sent to the browser
(client) and displayed. Server-side programming can be encrypted when users send
B- Com III – Web Programming
56 Apoorva Publishers
form variables, ensuring more security. Some examples of server-side
programming languages are ASP, C#, VB.NET, and PHP.

Advantages:
 Server-side scripting does not have any browser limitations.
 It can produce the output irrespective of browsers.
 Server-side scripts are more secure than client-side because it can use
encryption.
 Server-side scripts have greater access to the information and functions
available on the server.

Disadvantages:
 Server-side scripts require that their language's interpreter be installed on the
server.
 They create burden on the server resulting more network traffic.

Examples: Tasks done on the server side include the following.


 Keeping track of number of visitors to a website
 Database transactions
 Authorization to accessing websites
 E-mail transactions and etc

Program: The following program is simple example for server side programming
that uses ASP. The HTML file submits the name value to the server-file which in
turn directs the output to browser.

Test.asp
<%
response.write ("Hello " & _
request.querystring("t1"))
%>

Test.html
<form name="frm"
action="http://localhost/myprg/test.asp">
Name: <input type="text" name="t1" > <BR>
<input type="submit" name="submit">
</form>

4. How do you write a VBScript Program (Structure)? How a VBScript program gets
executed?
A VBScript program can be written in three different ways as shown below:

B- Com III - Web Programming


Apoorva Publishers 57
1. Embedding the code in <BODY> tag
2. Embedding the code in <HEAD> tag
3. Writing an external file and linking it in HTML

1. Embedding the script in <BODY> tag: To embed the code in HTML file, we need to
use <SCRIPT> tag. Script tag allows specifying the scripting language used; Here,
the ‘langauge’ should be ‘VBScript’. The following program shows using script in
body tag.

<html>
<body>
<script language="VBScript">
document.write("Welcome to VBScript")
</script>
</body>
</html>

2. Embedding the script in <HEAD> tag: Embedding the script in <HEAD> tag is more
common than it is in <body> tag. We can also write procedures or functions that
can be invoked when an associated event triggers. There are a number of events
that will trigger the execution of a VBScript, like clicking on a form button, or when
the web page is loaded. The following program shows using script in head tag.

<html>
<head>
<script language="VBScript">
document.write("Welcome to VBScript")
</script>
</head>
<body>
<br> Welcome to Apoorva
</body>
</html>

3. Writing an external file and linking it in HTML: When the code is lengthy and has
more number of programs, it is a good idea to write it in a separate file for which
the extension should be “.vbs”. We, then include it in the HTML document by
specifying it in ‘src’ attribute of <script> tag. The following program shows
including script file.

First prepare a .vbs file by writing the required script code in that. Example is
shown below.

Code in “s1.vbs”:
B- Com III – Web Programming
58 Apoorva Publishers
Msgbox "I am invoked through external file"

Now, write the HTML file and specify the script file in ‘src’ attribute of script tag.

<html>
<head>
<script Language="VBScript" src="s1.vbs">
</script>
</head>
<body onload="f1">
Demo using External Script file
</body>
</html>

5. What is Event Driven Programming?

 Events are various actions that take place in a program. Script can be invoked
when an associated event triggers. VBScript allows for event driven programming.
 A function or procedure will be executed only when the associated event triggers.
 Events can be triggered by performing specified action on different form elements
or HTML elements such as buttons, checkboxes, radio buttons, form, table and so
on.
 Each element may support several different events. For example, The <body> tag
supports the events like onclick, onload, onunload, onmousedown an etc.

6. What are Variables? How do you declare variables in VBScript?

Variable: Variable is a named storage location that can contain data i.e. it is a
placeholder of a value. VBScript does not demand variable declaration; because it is a
loosely typed programming language Each variable has a name that uniquely identifies
it within its level of scope. The following are the rules for giving Variable names:
 Must begin with an alphabetic character.
 Can't contain an embedded period or special characters (except underscore)
 Must be unique within the same scope.
 Must be no longer than 255 characters.
 Cannot include spaces
 A special character underscore ( _ ) can be used

Declaring Variables: There are many ways of declaring variables. The different ways of
declaring variables in VBScript are:
1. Implicit Declaration
2. Explicit Declaration

B- Com III - Web Programming


Apoorva Publishers 59
3. Using Option Explicit Statement

1. Implicit Declaration: In VBScript, we don't have to declare a variable before using


it. For example, we can write a scriptlet where we don't need to declare x,and y
before using it:

Example:
<html>
<body>
<script language="VBScript">
x=30
y=40
msgbox "sum=" & (x+y)
</script>
</body>
</html>

2. Explicit Declaration: It is always advisable to declare them explicitly. To declare a


variable explicitly, we can use the Dim statement, or public statement or private
statement.
 Private statement variables are available only to the script in which they are
declared.
 Public statement variables are available to all procedures in all scripts.
 Variables declared with Dim at the script level are available to all procedures
within the script. At the procedure level variables are available only within the
procedure.

Example:
<script language="VBScript">
private y
public z
Sub f1()
dim x
x=30
y=40
z=50
msgbox "sum = " & (x+y+z)
end sub
</script>
<body onload="f1">
</body>

3. Option Explicit Statement: To make declaration of variables compulsory, we place


the Option Explicit statement as the first statement in the script tag. When we use
B- Com III – Web Programming
60 Apoorva Publishers
this and variables are not declared, an error message appears. The following
program demonstrates this.

Example:
<html>
<body>
<script language="VBScript">
option explicit
dim x,y ‘declaration is compulsory here
x=30
y=40
msgbox "sum=" & (x+y)
</script>
</body>
</html>

7. Explain the Scope and Life of Variables. (Or) What are procedure-level and Script-level
Variables?

SCOPE and LIFE of Variables: Scope and Life of variables is determined by the location
where they are declared i.e. whether they are procedural-level or script-level.
 Script-level: If a variable is declared in the script section (outside the procedures),
it is called a script-level variable and the scope of this type of variable is in all the
procedures; and the life is until the script finishes its execution.
 procedure-level: If a variable is declared within the procedure, it is called a
procedure-level variable and the scope of this type of variable is within that
procedures; and the life is until the control comes out of that procedure.

Example:
<script language="VBScript">
Dim x ‘script-level varibale
X=40
Sub f1()
Dim y ‘procedure-level varibale
End sub
Sub f2()
z=x ‘we can access ‘x’throughout the script
End sub
</script>

8. What are Constants? Explain Constants in VBScript.

B- Com III - Web Programming


Apoorva Publishers 61
CONSTANTS: Constants are values which can never be changed. Constants can be
directly used in expressions or they are assigned to variables. VBScript supports both
explicit and implicit constants.

1. Implicit constants: Implicit constants are pre-defined by VBScript. Some of the


VBScript implicit constants begin with a vb prefix like VbYes, VBLongDate and so
on. VBScript defines the different categories of intrinsic constants such as color
constants (vbRed, vbGreen), date constants (vbMonday) and so on.

2. Explicit Constants: These are defined by the user in a program. These constants
can be assigned to any variable in VBScript without declaring the type. Following
are different types of explicit constants.
 Integer constants: There are three types of integers, namely, decimal, octal
and hexadecimal integers. Ex: 30, 40, 1e (hex).
 Float constants: They are whole numbers followed by a decimal point and
fractional part. They may be expressed in scientific (exponential) notation. Ex:
3.14, x=0.64e4
 String/Char constants: VBScript treats character and string constants same.
Strings must be enclosed in double quotes. Ex: “kiran”, “1234”
 Boolean (logical) constants: Boolean constants are true and false.
 Date constants: These values indicate date and time values. Date and time
literals are represented by enclosing them in number signs (#). Ex:
#12/7/2000#

9. Explain the Operators in VBScript.


VBScript has a full range of operators, including arithmetic operators, comparison
operators, logical operators and few additional operators. When several operations
occur in an expression, it is evaluated in a predetermined order, which is known as
operator precedence. The elements on which operands are applied are called
operands. The following tables list different operators used in VBScript.

Arithmetic Operators:

Operators Description Example Result


+ Addition 2+3 5
- Subtraction 3-2 1
* Multiplication 3*2 6
/ Floating point division 8/5 1.6
\ Integer division 8\5 1
Mod Remainder 8 Mod 5 3

B- Com III – Web Programming


62 Apoorva Publishers

^ To raise a number to the power of an 2^3 8


exponent
- Unary minus (negation) X=3 X=-3
X=-X

Comparison Operators:

Operators Description Example Result


> Greater than 3>2 True
< Less than 3<2 False
>= Greater than or Equal to 3 >= 2 True
<= Less than or Equal to 3 <= 2 False
= Equal to 2=2 True
<> Not Equal to 3 <> 2 True

Logical Operators:

Operators Description Example Result


And Performs logical Conjunction. Both the 3>2 And 3<4 True
operands should be true to be true.
Or Performs logical disjunction. If any one of 3>2 Or 3=4 True
the operands is true, it is true.
Not Performs logical Negation. True will be Not 3>2 False
false and vice versa.
Eqv results in True when both operands are true Eqv true true
True or both operands are False
Imp results in True in all cases when the false Imp false true
second operand is True or when both
operands are False.
Xor Performs logical Exclusion. Only one 3<2 xor 3<4 true
operand should be true to be true

Other Operators:

Operators Description Example Result


Is To determine if one object reference is document is True
the same as another. document

B- Com III - Web Programming


Apoorva Publishers 63
& Concatenation “Ravi” & RaviVarma
“Varma”

10. Explain Control Structures in VBScript.

VBScript provides several types of control structure. They control the execution order
and number of times a block of statements gets executed etc. The types are given
below.
1. Branching (Conditional) Control Structures
2. Iterative Control Structures (loops)
3. Exit statements

Note: Also, Refer to the following three questions.

11. Explain Branching Control Structures in VBScript.

Branching (Conditional) Structures: Branching Structures are used to choose among


alternative statements of an action. VBScript provides the following branching
structures.

 If … Then … End If
 If … Then … Else … End If
 If … Then … ElseIf … End If
 Select Case … End Select

If … Then … End If: The If...Then structure performs an indicated action only when the
condition is True; otherwise the action is skipped. If...Then statements can use either
single-line or multiple-line syntax.

Single line:
If condition Then statement

Multiple line:
If condition Then
statements
End If

The statements are executed only when the condition is true. The condition is usually a
comparison. In the single-line version End If statement is not used. It is used to execute
only one statement based on a condition. The multiple-line version can execute one or
more statements. The following program demonstrates If Then Structure:
B- Com III – Web Programming
64 Apoorva Publishers
<script language="VBScript">
age=25
if age>22 then
document.write "Get Ready for Marriage"
end if
</script>

If … Then … Else … End If: An If...Then... Else block allows us to define two blocks of
code. “then” block gets executed when the condition is true and “else” block gets
executed when the condition is false.

If condition Then
statements
Else
statements
End If

The following program uses if then else to find out whether the number is even or odd

<script language="VBScript">
x=4
If x Mod 2 = 0 Then
document.write "even"
Else
document.write "odd"
End If
</script>

If … Then … ElseIf … End If: If...Then.....Elself statements are like If...Then...Else


statements except that they allow our program to choose from more than two
alternatives. The If.... Then...Elself statement uses the following syntax:

If condition Then
Statements
Elself condition2 Then
Statements
Else
Statements
End If
The following program uses if then elseif structure

<script language="VBScript">
x=MsgBox("Are U OK?", vbYesNoCancel, "Message")
If x=vbYes Then

B- Com III - Web Programming


Apoorva Publishers 65
MsgBox "Yes is selected"
ElseIf x=vbNo Then
MsgBox "No is selected"
Else
MsgBox "Cancel is selected"
End If
</script>

Select Case … End Select: Select Case structures are similar to If...Then...Elself
structures. They allow the program to choose from more than two alternatives. In
other words, the result of the testexpression is compared against multiple values to
determine which code block should be invoked. The syntax is shown below.

Select Case testexpression


Case constant1
statements
Case constant2
statements
.
.
Case Else
statements
End Select

The following program illustrates the usage of select case structure.

<script language="VBScript">
i=MsgBox("Are U OK?",vbYesNoCancel,"Message")
Select Case i
Case vbYes
MsgBox "Yes is selected"
Case vbNo
MsgBox "No is selected"
Case Else
MsgBox "Cancel is selected"
End Select
</script>

12. Explain Iterative Control Structures (Loops) in VBScript.

Iterative Structures (loops): Repetition structures allow a block of statements to get


executed repetitively. The following are the iterative structures provided with VBScript.
 Do While / Loop
 Do / Loop While
B- Com III – Web Programming
66 Apoorva Publishers
 Do Until/ Loop
 Do / Loop Until
 While ...Wend
 For ... Next
 For Each ... Next

Do While/Loop, Do/Loop While: These loops execute the statements until the given
condition becomes false. Do While/Loop structures check the condition before
executing the code. Do/Loop While structures executes the code and then check the
condition.

Do Until/Loop, Do/ Loop Until: These loops execute the statements until the condition
becomes true. Do Until/Loop structures check the condition before executing the code.
Do/Loop Until structures executes the code and then check the condition.
Do-Loops syntaxes are shown below.
 Do While/Until condition
Statements
Loop
 Do
Statements
Loop While/Until condition

The following program uses “Do While/Loop” to print the given message 10 times

<script language="VBScript">
x=0
Do While x <10
document.write "<BR> To Be or Not to be"
x=x+1
Loop
</script>

The following program uses “Do Loop/Until” to print the given message 10 times

<script language="VBScript">
x = 0
Do
document.write "<BR> Just Do it"
x=x+1
Loop Until x=10
</script>

B- Com III - Web Programming


Apoorva Publishers 67
While ...Wend: Statements in while…Wend get executed as long as the condition is
True. It Quits that structure when the condition becomes False. It checks the condition
before executing the statements. The Syntax is shown below.

While condition
Statements
Wend

The following program prints the given message 10 times

<script language="VBScript">
x=0
While x <10
document.write "<BR> Great Job"
x=x+1
Wend
</script>

For ... Next, For Each ... Next: The For...Next Loop is another way to make loops in
VBScript. The For...Next statement executes a code block a specific number of times.
The counter value in a For.... Next structure can either increase or decrease depending
on whether step is positive or negative. For Each…Next refers to each member of the
array or collection. The Syntax for both are shown below.

 For counter = <start> to <end> [step increment]


Statements
Next

 For Each <element> In <Array>


Statements
Next
The following program uses “for” to print first 5 even numbers

<script language="VBScript">

For k = 2 To 10 step 2
document.write "<br>" & k
Next
</script>

The following program uses “for each” to print the elements of the array

<script language="VBScript">
x = Array(10, 20, 30)
B- Com III – Web Programming
68 Apoorva Publishers
For Each k In x
document.write "<br>" & k
Next
</script>

13. Explain Exit Statements in VBScript.

Exit Statements: VBScript also provides exit statements to bring out the control from
loops or sub-procedures or function procedures.
 Exit Do
 Exit For
 Exit Sub
 Exit Function

Exit Do: “Exit Do” makes the control quit the corresponding Do Loop and continues
with the remaining part of the program.

Exit For: “Exit For” makes the control quit the corresponding For Loop and continues
with the remaining part of the program.

The following program uses “exit for” and prints “Hello” for 5 times only.
<script language="VBScript">
For x = 1 To 10
Document.write "<br> Hello"
x = x + 1
If x = 5 Then Exit For
Next
</script>

Exit Sub: “Exit Sub” makes the control quit the corresponding Subroutine and returns
to the point from where the function is called. The following program prints “Hello”
and “Everybody”.
<script language="VBScript">
Display
Sub Display()
Document.write "Hello"
Exit Sub
Document.write "World"
End Sub
</script>

Exit Function: “Exit Function” makes the control quits the corresponding Function and
returns to the point from where the function is called. The following program
demonstrates “Exit Function”
B- Com III - Web Programming
Apoorva Publishers 69
<script language="VBScript">
Document.write GetRoot(16)‘prints 4
Document.write GetRoot(-9)‘doesn’t print anything
Function GetRoot(x)
If x < 0 Then Exit Function
GetRoot = Sqr(x)
End Function
</script>

14. Explain With Statement (with/end with) in VBScript.

With Statement: ‘With’ statement executes a series of statements on a single object. It


allows us to perform a series of statements on a specified object without writing the
name of the object repeatedly. For example, to change a number of different
properties on a single object, we place the property assignment statements within the
With control structure, referring to the object once instead of referring to it with each
property assignment.

Syntax:
With object
statements
End With

Example: The following program illustrates use of the With statement to assign values
to several properties (title, bgcolor, fgcolor, and write) of the object ‘document’.

<script language="VBScript">
with document
.title = "with demo"
.bgcolor = "yellow"
.fgcolor = "blue"
.write ("Hello Apoorva")
end with
</script>

15. Explain various Functions in VBScript.

There are many predefined functions in VBScript. They enhance the functionality of the
scripts. Following are the different categories of predefined (built-in) functions.
1. Math (Number) Functions
2. String (Text) Functions
3. Date and Time Functions
4. Conversion Functions
B- Com III – Web Programming
70 Apoorva Publishers
5. Formatting Functions
6. Logical Functions
7. Miscellaneous Functions
8. Array Functions

Note: Also, Refer to the following Eight questions.

16. Explain Math (Number) Functions in VBScript.

Function Purpose Example Result


Abs Returns Absolute value Abs(-3) 3
Sqr Returns Square Root Sqr(16) 4
Int Returns Integer value Int(76.45) 76
Fix Truncates the decimal part Fix(-5.3) -5
Sgn If it is a positive number, it returns 1, if it Sgn(-3) -1
is negative it returns -1 and if it is 0, it
returns 0
Sin(x) Returns Sine value of x Sin(0) 0
Cos(x) Returns Cosine value of x Cos(0) 1
Tan(x) Return tangent of x Tan((45*3.14)/180) 1
Atn(x) Return arc tangent of x (Atn(1)*180)/3.14 45
Log (x) Return log of x Log(7.389056) 2.0
Exp(x) Return Exponent of x (ex) Exp(1) 2.71828

Rnd() Returns a random number less than 1 Rnd() a random


but greater or equal to 0 value
Round() Rounds a number Round(6.467,2) 6.47

17. Explain String (Text) Functions in VBScript.

Function Purpose Example Result


StrComp() Compares two strings. Returns the StrComp(“AB”, ”AB”) 0
value indicating the result of
comparison

B- Com III - Web Programming


Apoorva Publishers 71
SrtReverse() Reverses the sting StrReverse (“RAMA”) AMAR
Left() Returns String containing a specified Left(“APOORVA”, 2) AP
number of characters from the left
side of a string.
Right() Returns a String containing a Right(“ABCD”,2) CD
specified number of characters from
the right side of a string.
Mid() Returns a String containing a Mid(“VARMA”,2, 3) ARM
specified number of characters from
a given position in a string.
String() Creates a string of repeating String(3, "$") $$$
characters
InStr() It returns the position of the sub string InStr(1, "This is", "is") 3
in main string from the specified
starting position. (from left side)
InStrRev() It returns the position of the sub InStrRev("This is", "is", 6
string in main string from the Len("This is"))
specified starting position. (from
right side)
Space() Creates the required space between "A" & Space(3) & "B" A B
strings. (3 spaces
within)
Ucase Returns the upper case string UCase("apple") APPLE
Lcase Returns the lower case string LCase("APPLE") apple
Trim Removes spaces both the sides of a Trim(" ABC ") ABC
string
LTrim Removes spaces Left side of a string LTrim(" ABC") ABC
RTrim Removes spaces Right side of a string RTrim("ABC ") ABC
Len Returns number of characters in a Len(“APOORVA”) 7
string
Replace Replaces the occurrences of search Replace("ABXYAB", UVXYUV
string with the replace string "AB", "UV")

18. Explain Date and Time Functions in VBScript.

Function Purpose Example Result


Date To print the current Date Current date
date

B- Com III – Web Programming


72 Apoorva Publishers
Time To print the current Time Current time
time
Now To print the current Now Current date
date and time and time
Year() Returns Year part of a Year (#2-28-1975#) 1975
date
Month() Returns Month part of Month 12
a date (#12-28-1975#)
Day() Returns Day part of a Day (#12-28-1975#) 28
date
WeekDay() Returns a number WeekDay 1 i.e. Sunday
corresponding to a (#12-28-1975#)
week day of a date
WeekDay Returns weekday WeekdayName (Weekday Sunday
Name() name as of the (#12/28/1975#))
number given
MonthName Returns month name MonthName(1) January
as of the number given
Hour() Returns Hour part of a Hour(#10:40:56#) 10
time
Minute() Returns Minute part of Minute (#10:40:56#) 40
a time
Second() Returns second part of Second (#10:40:56#) 56
a time
DatePart Returns a part of a DatePart (“d”, 28
date as specified ( #12/28/1975#)
d,m,yyyy,h,n,s) DatePart (“m”, 12
#12/28/1975#)
DateAdd Adds a part to a date DateAdd (“d”,5, 1/2/76
#12/28/1975#)
DateAdd (“yyyy”,5, 12/28/80
#12/28/1975#)
DateDiff Return difference DateDiff("d", #12/22/1975#, 6
between similar parts #12/28/1975#)
of two dates
DateValue Converts a string to DateValue 8/7/99
date (“Aug 7 1999”)
DateSerial Creates date from DateSerial(99,10,9) 10/9/99
three different
arguments (y,m,d)

B- Com III - Web Programming


Apoorva Publishers 73
TimeValue Converts a string to TimeValue(“4:50”) 4:50:00 AM
time
TimeSerial Creates time from the TimeSerial(10,40,53) 10:40:53 AM
three given arguments
(h,m,s)
FormatDateTime Returns an expression FormatDateTime(Date,1) Monday,
formatted as a date or November
time 20, 2010

19. Explain Conversion Functions in VBScript.

In Conversion functions, there are two types: 1) Value Conversion functions and 2)
Type Conversion (data type conversion) functions.

Value Conversion functions:

Function Purpose Example Result


Chr Converting ASCII to character Chr(65) A

Asc Converting character to ASCII Asc(“A”) 65

Hex Converts the number to Hexa decimal Hex(30) 1E

Oct Converts the number to Octal Oct(30) 36

Type Conversion functions:

Function Purpose Example Result


CInt Converts a value to Integer Cint(“123”) 123 as number

CStr Converts value to string CStr(123) 123 as string


CDbl Converts number to double CDbl(123) 123 as double
CBool Converts expression to Boolean CBool(123) True
value true or false
CByte Converts expression to byte CByte(123) 123 as byte

CCur Converts number to Currency CCur(123) 123 as currency


CSng Converts expression to single CSng(123) 123 as single

B- Com III – Web Programming


74 Apoorva Publishers
CDate Converts expression to date CDate(123) 5/2/1900
CLng Converts number to long CLng(123) 123 as long

20. Explain Formatting Functions in VBScript.

Function Purpose Example Result


FormatNumber Returns an expression formatted FormatNumber( 123.46
as a number. 123.456, 2)
FormatPercent Returns an expression formatted FormatPercent( 6.25%
as a percentage (multiplied by 2/32)
100) with a trailing % character.
FormatCurrency Returns an expression formatted as a FormatCurrency( $1000.00
currency value using the currency 1000)
symbol defined in the control panel
FomatDateTime Returns an expression formatted FormatDateTime( Monday,
as a date or time Date,1) November
20, 2010

21. Explain Logical Functions in VBScript.

Function Purpose Example Result


IsNumeric true if numeric, false otherwise IsNumeric(123) True

IsDate true for a valid date IsDate(#12/4/1998#) True

IsNull true if Null value else false x = Null True


IsNull(x)
IsArray true if it is an Array else false x = Array(10, 20, 30) True
IsArray(x)
IsEmpty true if the expression is empty x = Empty True
IsEmpty(x)

22. Explain Miscellaneous Functions in VBScript.

Function Description
CreateObject Creates an object of a specified type
GetObject Returns a reference to an automation object from a file
GetRef Allows us to connect a VBScript procedure to a DHTML event on our pages

B- Com III - Web Programming


Apoorva Publishers 75
InputBox Displays a dialog box, where the user can write some input and/or click
on a button, and returns the contents
LoadPicture Returns a picture object.
MsgBox Displays a message box, waits for the user to click a button, and returns a
value that indicates which button the user clicked
RGB Returns a number that represents an RGB color value
SetLocale Sets the locale ID and returns the previous locale ID
GetLocale Returns the current locale ID
TypeName Returns the subtype of a specified variable
VarType Returns a value that indicates the subtype of a specified variable
Eval Evaluates an expression and returns the result

23. Explain Array Functions in VBScript with examples.

An array is a set of values of similar type. To work with arrays, VBScript provides several
built in functions: Array, IsArray, Join, Filter, Split, UBound, and LBound. The functions
are explained below.

1. Array: Array function allows us to define the array. Each individual element can
access the array element using an index, which starts from ‘zero’. The following
program demonstrates defining an array using ‘Array’ function.

<script language="VBScript">
s= Array("Rama", "Arun", "Amar", "Kiran")
For i = 0 To 3
document.write " " & s(i)
next
</script>

Output: Rama Arun Amar Kiran


2. IsArray: IsArray function returns true if the given variable is an array; otherwise it
returns false. The following program demonstrates the function.

<script language="VBScript">
s= Array("Rama", "Arun", "Amar", "Kiran")
document.write IsArray(s)
</script>

Output: True

3. Join: Join function returns a string created by joining a number of substrings


contained in an array. We can use a delimiting character that can be used to

B- Com III – Web Programming


76 Apoorva Publishers
separate the substrings. The syntax of Join function is: Join(list[,
delimiter])
The following example uses the Join function to join the substrings of
MyArray.

<script language="VBScript">
Dim MyArray(4)
MyArray(0) = "Apoorva"
MyArray(1) = "Degree"
MyArray(2) = "College"
str= Join(MyArray)
document.write str
</script>

Output: ApoorvaDegreeCollege

4. Filter: Filter function returns an array containing subset of a string array based on
specified filter criteria. The following example uses the Filter function to return the
array containing the search criteria "Mon":

<script language="VBScript">
Dim MyArray (3)
MyArray(0) = "Sunday"
MyArray(1) = "Monday"
MyArray(2) = "Tuesday"
str = Filter(MyArray, "Mon")
document.write str(0)
</script>

Output: Monday
5. Split: Split function returns one-dimensional array containing a specified number
of substrings. Here, we can use a delimiting character that can be used to identify
substring limits. The following example splits a string into an array of substrings

<script language="VBScript">
str = Split("VBScript-is-fun!", "-")
document.write str(0)
</script>
' str(0) contains "VBScript”
' str(1) contains "is"
' str(2) contains "fun!"

Output: VBScript

B- Com III - Web Programming


Apoorva Publishers 77
6. UBound, LBound: These functions are used to determine the upper bound and
lower bound values of an array i.e. the minimum and maximum index values.
<script language="VBScript">
str = Array("s1", "s2", "s3", "s4")
document.write "<BR> UBound = " & ubound(str)
document.write "<BR> LBound = " & lbound(str)
</script>

Output: UBound = 3
LBound = 0

24. Write a program to demonstrate Date and Time Functions.

Program:
<script language="VBScript">
document.write "<BR>Date and Time : " & Now
document.write "<BR>Date : " & Date
document.write "<BR>Time : " & Time
document.write "<BR>Year part : " & Year(Now)
document.write "<BR>Month part : " & Month(Now)
document.write "<BR>Hour part " & Hour(Now)
document.write "<BR>Difference between the dates : " & _
DateDiff("d", "10/7/1999", "10/15/1999")
document.write "<BR>Date after adding 5 days : " & _
DateAdd("d", 5, #10/7/1999#)
document.write "<BR>Day of the Date : " & _
DatePart("d", #10/7/1999#)
document.write "<BR>Formating date : " & _
FormatDateTime("10/3/1999",1)
</script>

Output:
Date and Time : 11/22/2010 9:44:39 PM
Date : 11/22/2010
Time : 9:44:39 PM
Year part : 2010
Month part : 11
Hour part 21
Difference between the dates : 8
Date after adding 5 days : 10/12/1999
Day of the Date : 7
Formating date : Sunday, October 03, 1999

B- Com III – Web Programming


78 Apoorva Publishers

25. Write a program to demonstrate String Functions.

Program:
<script language="VBScript">
document.write "<BR>" & StrComp("AB", "AB")
document.write "<BR>" & StrReverse ("RAMA")
document.write "<BR>" & Left("APOORVA", 2)
document.write "<BR>" & Right("ABCD",2)
document.write "<BR>" & Mid("VARMA",2, 3)
document.write "<BR>" & String(3, "$")
document.write "<BR>" & InStr(1, "This is", "is")
document.write "<BR>" & InStrRev("This is", "is",7)
document.write "<BR>" & "A" & Space(3) & "B"
document.write "<BR>" & UCase("apple")
document.write "<BR>" & LCase("APPLE")
document.write "<BR>" & Trim(" ABC ")
document.write "<BR>" & LTrim(" ABC")
document.write "<BR>" & RTrim("ABC ")
document.write "<BR>" & Len("APOORVA")
document.write "<BR>" & Replace("ABXYAB", "AB", "UV")
</script>

Output:
0
AMAR
AP
CD
ARM
$$$
3
6
A B
APPLE
apple
ABC
ABC
ABC
7
UVXYUV

26. Explain String Manipulation Mechanism with an example in VBScript.

B- Com III - Web Programming


Apoorva Publishers 79
String manipulation in VBScript can be performed using several built-in string functions
of VBScript. For example, ‘UCase()’ is a function which is used to convert the given
string into uppercase. Different string functions and program that uses the string
functions are given below.

String Functions:
Note: Refer to Question No: 17 in this chapter

A program that uses string functions for manipulation:


Note: Refer to Question No: 25 in this chapter

27. What are Arrays? How do you declare Arrays in VBScript? (Or) Explain Array Handling
in VBScript.

Array: An array is set of values of similar type. It is a sequential group of memory


locations, which have the same name. Individual elements of the array can be
differentiated using array index (subscript). Array index starts from zero (0). Every array
has upper and lower bounds. We can declare an array of simple data types and even
array of objects. VBScript allows two different ways to define arrays.
1. Using Dim Statement
2. Using ‘Array()’ Function

1. Using Dim Statement: Using this method, we first specify the size of the array and
have the elements later in the program. Array is supported by many functions like
“join”, “filter”, “split”, “uboud”, “lbound” and etc. For example, “ubound” function
gives the upper limit of the array. Following example demonstrates defining array
using “dim” statement.

<script language="VBScript">
dim a(10)
a(0)="Ramu"
a(1)="Arun"
a(2)="Kiran"
a(3)="Pavan"

for i=0 to 3
document.write(a(i) & "<br>")
next
</script>

2. Using “Array()” Function: We use this when we want to give the values, while
defining the array itself. Even this kind of array supports all the array functions.
Following example demonstrates defining array using “Array()” function
B- Com III – Web Programming
80 Apoorva Publishers

<script language="VBScript">
a=Array(10,20,30,40)
for i=0 to 3
document.write(a(i) & "<br>")
next
</script>

It is common practice to use for-each loop to print the array elements as shown
below. Here, ‘x’ refers to each element of the array and we don’t use indexes when
using for-each.

<script language="VBScript">
a=Array(10,20,30,40)
for each x in a
document.write(x & "<br>")
next
</script>

28. How do you write Comments in VBScript?

Giving comments is something like providing internal documentation within the


program. It is very useful to include comments because they enhance understandability
of the program. VBScript allows two different ways of commenting.

1. ' comment: This allows single line commenting. This can be written in a
separate line or alongside of a statement.
2. REM comment: Even this allows single line commenting. This requires a colon (:)
When it is written alongside of the code line; But, if REM comment is written in a
separate line colon is not needed. REM comment also requires a space between
REM and comment.

Example: Following program shows different ways of writing comments

<script language="VBScript">
Dim MyStr1, MyStr2
MyStr1 = "Hello" : Rem comment separated by a colon
MyStr2 = "Apoorva" ' This is also a comment
Rem This is also a comment but without a colon
</script>

29. What are Procedures? Explain Sub-Procedures and Functions in VBScript?

B- Com III - Web Programming


Apoorva Publishers 81
A procedure is a reusable block of statements that executes on calling or an
associated event triggers. VBScript facilitates two types of procedures.
1. Sub-Procedures
2. Function Procedures (or simply Functions)

1. SUB PROCEDURES: It is a reusable block of statements that does not return any
value. A sub procedure can be placed in a <sript> tag set. Each time the procedure
is called, the statements between Sub and End Sub are executed. The syntax for a
sub procedure is as follows:

sub procedurename(arg-list)
Statements
End Sub

Arglist is a list of argument names separated by commas. The arguments can be


Byref or Byval.
 By Ref: When an argument is sent as Byref, the value of the variable sent can
be modified by the procedure concerned. All the arguments are by default
Byref.
 By Val: If an argument is sent as Byval, only a copy of the variable is sent and
the procedure cannot affect the original value.

Example: The following procedure prints “Hello”

<script language="VBScript">
SayHello 'calling a procedure

Sub SayHello()
document.write "Hello from a function"
end sub
</script>

Procedure with arguments: We can send arguments to sub-procedures or


functions. Arguments are the values, which are sent to a function. We can also call
a procedure using ‘call’ statement. The following program demonstrates a
procedure that takes two arguments and using ‘call’ statement to call a procedure.

<script language="VBScript">
sum 30,40 'calling a procedure with arguments
call sum(80,90)'another way of calling a procedure
Sub sum(x,y)
document.write "<BR> Sum= " & (x+y)
end sub
</script>
B- Com III – Web Programming
82 Apoorva Publishers
2. FUNCTION PROCEDURES: Functions are like sub procedures, except that they
return a value to the calling procedure. The default value returned by a Function
procedure is a Variant. The syntax for a function procedure is as follows:

Function FunctionName (arg_list)


Statements
FunctionName=ReturnValue
End Function

Example: The following program uses a function that returns the factorial of a
given number.

<script language="VBScript">
document.write "Factorial of 4=" & Fact (4)
Function Fact (X)
F=1
For I=1 to X
F=F*I
Next
Fact=F
End Function
</script>

30. Explain Sub-Procedures in VBScript?

Note: Refer to section 1 (sub-procedures) in the previous question.

31. Explain Functions in VBScript

Note: Refer to section 2 (function-procedures) in the question no:

32. Explain how do you write a Procedure with Arguments in VBScript?

Note: Refer to section 1 (procedure with arguments) in the question no:

33. What are VBScript Dialog Boxes? (Or) Explain MsgBox and InputBox with examples.

Dialog Boxes: Dialog Boxes are used to display information to or retrieve information
from the user. They ask the user for the data needed to continue an application. Dialog
Boxes are either Modal or non-Modal. A Modal Dialog Box does not allow the user to
continue with other applications unless it is closed or unloaded. The non-Modal dialog

B- Com III - Web Programming


Apoorva Publishers 83
box allows shifting of focus between the dialog box and another form without closing
the dialog Box. VBScript provides two types of predefined dialog boxes: 1) Msgbox and
2) Inputbox.

1. MSGBOX: Displays a message in a dialog box, waits for the user to click a button,
and returns a value indicating which button the user clicked. The syntax of the
function, its arguments are shown below.

Syntax: MsgBox(prompt[, buttons][, title][, helpfile, context])


Arguments:
 Prompt: String displayed as the message in the dialog box.
 Buttons: Numeric value indicating the icon style to use, buttons, and the
modality of the message box. (vbOKOnly, vbOKCancel,
vbAbortRetryIgnore, vbYesNoCancel,vbYesNo,vbRetryCancel, vbCritical,
vbQuestion, vbExclamation, vbInformation and so on)
 Title: String displayed in the title bar of the dialog box.
 Helpfile: A String that identifies the Help file
 Context: A Number that identifies the Help context number

Example: The following example illustrates the use of the MsgBox function.

<script language="VBScript">
result = MsgBox ("Did U Like
VBScript?",vbYesNoCancel+vbQuestion, "My Question")
Select Case result
Case vbYes
Document.write "That’s nice. Go On exploring"
Case vbNo
Document.write "Concentrate More"
Case vbCancel
Document.write "U didn’t answer me"
End Select
</script>

2. INPUTBOX: Displays a prompt in a dialog box, waits for the user to input text or
click a button, and returns the contents of the text box.

B- Com III – Web Programming


84 Apoorva Publishers
Syntax: InputBox(prompt[, title][, default][, xpos][, ypos][,
helpfile, context])

Arguments:
 Prompt: String displayed as the message in the dialog box.
 Title: String displayed in the title bar of the dialog box.
 default: A default value displayed in the text box if the input is not
provided.
 ypos: x-position of the dialog box
 ypos: x-position of the dialog box
 Helpfile: A String that identifies the Help file
 Context: A Number that identifies the Help context number

Example: The following example uses the InputBox function to display an input box and
assign the string to the variable ‘str’

<script language="VBScript">
str = InputBox("Enter your name")
MsgBox ("Nice to meet you " & str)
</script>

34. What are the different user interaction elements present in VB script? (Or) How user
interaction can be achieved in VBScript? (Or) What is User Interaction? Write a
program to show how it can be performed using VBScript.
User Interaction is the ability of the user to work with the web page i.e. clicking the
buttons, entering values, changing the size, and etc. User interaction in VBScript can be
achieved through 1) VBScript’s own elements (dialog boxes) 2) HTML elements (like
buttons, text fields, and so on) combined with events.

1) VBScript’s own elements (dialog boxes): VBScript provides two elements for the
user interaction. They are
a) Msgbox:
Note: refer to section 1(Msgbox) in the previous question.
b) Inputbox:
Note: refer to section 2(Inputbox) in the previous question.
B- Com III - Web Programming
Apoorva Publishers 85
2) HTML elements with events: HTML elements include many graphical user
interfacing elements. Each of these elements can be associated with one more
events. If an event is triggered the related procedure will be executed. The
different elements are shown below.

Element Description
Text A single-line text input control
Textarea A multi-line text input control
Password A password input control
Label A label for an input element
Checkbox A checkbox that can be checked or unchecked
Radio A group of options in which only one can be selected
Button A push button that can be clicked to perform an action
Select A drop-down list control
Submit A button that sends information to server when clicked
Reset A button that clears form elements’ information

Events: Some of the common events that are supported by most of the above
controls are listed below.

Events Meaning
onclick When a mouseclick happens on an element
ondblclick When a mouse-doubleclick happens on an element
onblur When an element loses focus
onfocus When an element gets focus
onkeydown When a keyboard key is pressed
onkeyup When a key is released
onkeypress When a keyboard key is pressed or held down
onmousedown When a mouse button is held down
onmouseup When mouse button is released
onmousemove When mouse moves
onmouseout When muse cursor is moved out of the control
onmouseover When mouse moves over the control

Example: The following program uses a button control with onclick() event.

<script language="VBScript">
sub B1_OnClick()
msgbox "U Clicked Me"
end sub
</script>

<body>
<form>
B- Com III – Web Programming
86 Apoorva Publishers
<input type=button value="Click Me" name="B1">
</form>
</body>
The above program displays a button and it gives a message through msgbox
when we click on that.

35. Write a program to display a message box while clicking on the button using VB script.

Note: Refer to the ‘example’ program in the previous question.

36. Discuss about Dynamic Content with an example.

HTML is capable of producing only static pages i.e. the information that it shows in a
page cannot be user-specific and it cannot facilitate user interaction. But, dynamic
content can very well facilitate user interaction or the pages can be made user-specific
and time-specific or it allows the users to set their own settings to view pages.

For example, a page may recognize the user and greet him with his name or it may ask
the user to fill in information and perform validity or calculations on it.

To design a web site with dynamic content, we need a set of technologies like HTML,
CSS, JavaScript/VBScript, XML and etc.

Example: Following is a simple program that displays running time like a digital clock
i.e. the time value in the page changes automatically as the time changes.

<script language="VBScript">
sub f1()
head1.innerHtML = time
end sub
set t=setInterval("f1()",1000)
</script>

<body>
<h1 id="head1"> </h1>
</body>
B- Com III - Web Programming
Apoorva Publishers 87
37. What are Run-Time Errors in VBScript? (Or) What are different types of errors?

The two different types of errors present in a program are: 1) Syntactical errors and 2)
Run-time errors.

1. Syntactical errors: These errors do not allow the execution of the program. They
violate the syntax of different constructs of a program. For example, missing a semi
colon, unterminated string, object expected are some of syntactical errors.

2. Runtime errors: VBScript run-time errors are errors that result when some script
attempts to perform an action that the system cannot execute. VBScript run-time
errors occur while the script is being executed or when variable expressions are
being evaluated or when memory is dynamically allocated. When runtime error
occurs, a program will be terminated abruptly i.e. the program stops from being
executed. To avoid this, we use Error handling. The following program raises a
runtime error called ‘Division by zero’ when y (denominator) value is ‘zero’.
Otherwise, it will be executed normally.

<script language="VBScript">
x=inputbox("Enter x value")
y=inputbox("Enter y value")
document.write "Div = " & (x/y)
document.write "<br>Thank you"
</script>

The output of the above program will be:


Case 1: if x is 8 and y is 4
Div = 2
Thank you
Case 2: if x is 8 and y is 0
Yields nothing because it raises error

Some of the common run time errors in VBScript are listed below. Every runtime error
is associated with a number. For example, the number for ‘Division by zero’ is 11.

 Division by zero  Out of stack space


 For loop not initialized  Overflow
 Argument not optional  Sub or function not defined
 Internal error  Subscript out of range
 Invalid picture  Syntax error in regular expression
 Invalid procedure call or argument  Type mismatch
 Invalid use of Null  Variable is undefined
 Out of Memory  Class not defined
B- Com III – Web Programming
88 Apoorva Publishers

38. Explain Error Handling in VBScript. (Or) Explain Handling runtime Errors in VBScript.

When a runtime error occurs, a program will be terminated abruptly i.e. the program
stops from being executed. To avoid this, we use Error handling.

Error handling: Error handling is a mechanism to handle runtime errors. Error handling
enables programmers to write error-free programs. Proper error handling ensures safe
termination of a program. We use ‘on error resume next’ statement to handle runtime
errors in VBScript.

This statement enables an error trap and moves the control to the next statement to
the statement that caused error. This is where error handling is written.

Syntax of handling error:


<script language="VBScript">
On Error resume next
Code in which we expect error
Error handling code
</script>

Example: The following program demonstrates error handling

<script language="VBScript">
On Error resume next
x=inputbox("Enter x value")
y=inputbox("Enter y value")
document.write "Div = " & (x/y)
if err.number = 11 then
document.write "Denominator cannot be a zero"
end if
document.write "<br>Thank you"
</script>

The output of the above program will be:


Case 1: if x is 8 and y is 4
Div = 2
Thank you
Case 2: if x is 8 and y is 0
Denominator cannot be a zero
Thank you

39. What is Err Object? What are its Properties and Methods?

B- Com III - Web Programming


Apoorva Publishers 89
The Err Object provides information about the raised runtime error. Using Err object
allows the programmer to provide detailed error information.

Err Object Properties:


 Number: The Number property is an integer that indicates the last error that
occurred. To determine which error has occurred, we check the value of
Err.Number.
 Description: The Description property is a string that contains a description of the
error.
 Source: The Source property contains the name of the object application that
generated the error.

Err Object Methods:


 Clear: The Clear methods set the value of Err.Number to zero.
 Raise: The Raise method causes an error. We use the Raise method to re-throw
errors, or to raise user defined errors

Example: Following program demonstrates the use of ‘Err’ object and its properties
and methods.

<script language="VBScript">
On Error resume next
x=8
y=0
document.write "Div = " & (x/y)
if err.number <> 0 then
document.write "Number: " & err.number
document.write "<br>Description:" & err.description
document.write "<br>Source: " & err.source
err.clear
end if
</script>

Output: Following is the output of the above program


Number: 11
Description: Division by zero
Source: Microsoft VBScript runtime error

40. What is Data Validation (Form Validation)? Write a program to show how data
validation is performed using VB Script. (Or) Write notes on Data Validation.

B- Com III – Web Programming


90 Apoorva Publishers
Client side data validation can be very easily performed by VBScript. Data Validation is
a process of verifying the correctness of values entered by the user. For example, a
name cannot contain digits and a pin-code cannot contain alphabets. If we don’t
perform data-validation, incorrect data is submitted to server and may cause serious
problems to the database. There are several types of data validation procedures. The
common ones are explained below.

 Data type validation: Whether the data-type of the value matches with the one
required or not. For example, name cannot be a number.
 Value Validation: Whether the value is in a required format or not. For example, e-
mail id should have proper format.
 Range checking: whether the value is within the expected range or not. For
example, Marks cannot be less than ‘0’ or greater than ‘100’.
 Data Existence: whether the given value exists or not. For example, course exists in
a college or not.

Example: The program given below performs the following data validations.
1. Name should contain only letters (it should not contain digits and special
characters)
2. Rno should be numeric
3. Date-of-Birth should be a valid date.

The program when executed, will not allow invalid values for the said fields. In the case
of invalid data it gives a message and stays in the same page to facilitate re-entry of
data i.e. it will not submit the data to the server. If and only if all the fields have valid
data, they will be submitted to server.

<script language="VBScript">

function frm_OnSubmit()
dim val
val=true
s1=trim(frm.t1.value)
s2=trim(frm.t2.value)
s3=trim(frm.t3.value)

if s1="" or not isWord(s1) then


msgbox "Invalid Name"
B- Com III - Web Programming
Apoorva Publishers 91
val=false
end if

if s2="" or not isNumeric(s2) then


msgbox "Invalid Rno"
val=false
end if

if s3="" or not isDate(s3) then


msgbox "Invalid Date of Birth"
val=false
end if
frm_OnSubmit=val
end function

function isWord(s)
for i=1 to len(s)
v= asc(mid(s,i,1))
if v<65 or v>122 or (v>90 and v<97) then
isWord=false
exit function
end if
next
isWord=true
end function

</script>

<body>
<form name="frm" action="test.asp">
Name: <input type="text" name="t1" > <BR>
R.No : <input type="text" name="t2" > <BR>
DOB : <input type="text" name="t3" > <BR>
<input type="submit" name="Submit Form" value="Submit Form">
<input type="reset" value="Clear Form">
</form>
</body>

41. Write a program of Student Registration form using VB script. Write necessary
validations.
The following program displays a student registration form and performs data
validation on the following fields.
1. Name should contain only letters (it should not contain digits and special
characters)
2. Date-of-Birth should be a valid date.
3. City should contain only letters
4. Pin should be numeric and should have six digits.
B- Com III – Web Programming
92 Apoorva Publishers
The program when executed, will not allow invalid values for the said fields. In the case
of invalid data it gives error messages within the page and stays in the same page to
facilitate re-entry of data i.e. it will not submit the data to the server. If and only if all
the fields have valid data, they will be submitted to server.

<script language="VBScript">

function frm_OnSubmit()
dim val
NameERR.innerHTML=""
CityERR.innerHTML=""
PinERR.innerHTML=""
DobERR.innerHTML=""
s1=trim(frm.sname.value)
s2=trim(frm.city.value)
s3=trim(frm.pin.value)
s4=trim(frm.dob.value)
val=true
if s1="" or not isWord(s1) then
NameERR.innerHTML="Invalid Name"
val=false
end if

if s2="" or not isWord(s2) then


CityERR.innerHTML="Invalid City"
val=false
end if

if s3="" or not isNumeric(s3) or len(s3)<>6 then


PinERR.innerHTML="Invalid Pin"
val=false
end if

B- Com III - Web Programming


Apoorva Publishers 93
if s4="" or not isDate(s4) then
DobERR.innerHTML="Invalid Date of Birth"
val=false
end if
frm_OnSubmit=val
end function

function isWord(s)
for i=1 to len(s)
v= asc(mid(s,i,1))
if v<65 or v>122 or (v>90 and v<97) then
isWord=false
exit function
end if
next
isWord=true
end function

</script>

<body>
<center>
<h2> College Registration Form </h2>
<form name="frm" action="test.asp">

<table border="0" style="font-size=25">


<tr>
<td>Name: </td>
<td><input type="text" name="sname">
<span id="NameERR" style="color:red"></span></td>
</tr>

<tr>
<td>Date of Birth: </td>
<td><input type="text" name="dob">
<span id="DobERR" style="color:red"></span></td>
</tr>
<tr>
<td>Course: </td>
<td><select name="course">
<option value="BSc">BSc</option>
<option value="BCom">BCom</option>
<option value="BBM">BBM</option>
<option value="BA">BA</option>
</select> </td>
</tr>
<tr>
<td>City: </td>
<td><input type="text" name="city">
<span id="CityERR" style="color:red"></span></td>

B- Com III – Web Programming


94 Apoorva Publishers
</tr>

<tr>
<td>Pin: </td>
<td><input type="text" name="pin">
<span id="PinERR" style="color:red"></span></td>
</tr>

</table>
<br>
<input type="submit" name="Submit Form" value="Submit Form">
<input type="reset" value="Clear Form">
</form>
</center>
</body>

42. Using VBScript, Design a webpage of Student Registration form for a Computer
Institute.

Note: Refer to the above program. Do the necessary changes to “course” field i.e. the
options for this field can be “c”, “c++”, “java”, “oracle” and etc.

43. Write a program in VB Script for adding any two numbers.


The following program uses two text boxes to receive two values and button which on
clicking gives the sum of the two given numbers.

<script language="VBScript">
sub B1_OnClick()
x = int(frm.t1.Value)
y = int(frm.t2.Value)
document.write "<h1>Sum = " & (x+y) & "</h1>"
end sub
</script>

<body>
<form name="frm">
Enter X Value: <input type=text name="t1"> <br>
Enter Y Value: <input type=text name="t2"> <br>

B- Com III - Web Programming


Apoorva Publishers 95
<input type=button value="Add" name="B1">
</form>
</body>

44. What are Script engines and how they are helpful? Explain.

 The script engine implements all the functions and procedures that can be used in
script programs.
 Without script engine, we cannot execute our script programs.
 Script engines are provided by the operating system itself.
 The browser identifies the language of the script, and then calls the appropriate
scripting engine.
 There are also built-in methods to identify the script engine type and versions. The
methods are used in the following program.

<script language="VBScript">
document.write(ScriptEngine & "<br>")
document.write(ScriptEngineBuildVersion & "<br>")
document.write(ScriptEngineMajorVersion & "<br>")
document.write(ScriptEngineMinorVersion)
</script>

The program gives the following output:


VBScript
23000
5
8

 On the other hand, there exist server-side script engines like the ASP engine. This
is installed on the web server and is responsible for processing ASP scripts. It is the
responsibility of ASP engine to process the ASP scripts and send the results back as
HTML text to the client. The ASP engine also invokes vbscript.dll to run VBScript
scripts.

B- Com III – Web Programming


96 Apoorva Publishers

3 DHTML
1. What is DHTML? What are its Advantages and Disadvantages?
2. Write the difference between HTML and DHTML.
3. Discuss about Cascading Style Sheets (CSS) with example.
4. How many types of style sheets are existing in DHTML? Explain with an
example. (Or) Explain about (i) Style Sheets (ii) External Style Sheets (iii)
Embedded Style Sheets (iv) Inline Style Sheets.
5. Explain Inline Style Sheets with an example.
6. Explain Embedded Style Sheets with an example.
7. Explain External (Linked) Style Sheets with an example.
8. Explain Imported Style Sheets with an example.
9. Explain different types of Selectors used in style sheets.
10. Discuss Style Classes with an Example.
11. Explain Text Properties in CSS (DHTML).
12. Explain Font Properties in CSS (DHTML).
13. Explain Background Properties in CSS (DHTML).
14. Explain Border Properties in CSS (DHTML).
15. Explain Margin Properties in CSS (DHTML).
16. Explain Positioning and Display Properties in CSS (DHTML).
17. Explain Dimension Properties in CSS (DHTML).
18. Explain List Properties in CSS (DHTML).
19. Explain Table Properties in CSS (DHTML).
20. How to position the following elements using style sheet? Write a program
to position three images as shown in the figure below.
21. What is an Event? Explain Event handling in DHTML. (Or) Discuss about
Dynamic HTML Event Model with the help of an example.
22. Write short notes on ONCLICK event with example.
23. Write short notes on ONDBLCLICK event with example.
24. Write short notes on ONMOUSEOVER, ONMOUSEOUT events with an
example.
25. Write short notes on ONMOUSEUP, ONMOUSEDOWN, ONMOUSEMOVE
events with an example.
26. Explain “Mouse events” with examples.

B- Com III - Web Programming


Apoorva Publishers 97
27. Write short notes on ONKEYDOWN, ONKEYUP, ONKEYPRESS events with
example. (Or) Explain Keyboard related events.
28. Write short notes on ONFOCUS, ONBLUR events with an example.
29. Write short notes on ONCHANGE event with example.
30. Write short notes on ONLOAD, ONUNLOAD events with example.
31. Write short notes on ONSELECT event with example.
32. Write short notes on ONSUBMIT event with example.
33. Write short notes on ONRESET event with example.
34. Write short notes on ONERROR event with example.
35. Explain about the "CreateElement" method in Dynamic content.
36. Write a program to Create a table dynamically and Add/Delete rows
dynamically in DHTML.
37. With an example, explain how to change text, attributes, style, and
graphics dynamically.
38. What is a filter? What are different filters in DHTML?
39. What are transitions? What are different transition filters? (Or) Discuss
about the transitions of Visual Effects with an example.
40. How Multimedia effects can be created using DHTML? (Or) Discuss about
Filters and Transitions existing in DHTML in detail.

B- Com III – Web Programming


98 Apoorva Publishers

1. What is DHTML? What are its Advantages and Disadvantages?

DHTML: DHTML stands for dynamic HTML. DHTML is not a programming or markup
language like HTML. It is a term that is used to describe the creation of dynamic and
interactive pages. One of the advantages of DHTML for web design and clients is that it
can combine the use of HTML, JavaScript/VBScript, XML and CSS (Cascading Style
Sheets).

HTML is capable of producing only static pages i.e. the information that it shows in a
page cannot be user-specific and it cannot facilitate user interaction. But, dynamic
content can very well facilitate user interaction or the pages can be made user-specific
and time-specific or it allows the users to set their own settings to view pages.

For example, a page may recognize the user and greet him with his name or it may ask
the user to fill in information and perform validity or calculations on it.

To design a web site with dynamic content, we need a set of technologies like HTML,
CSS, JavaScript/VBScript, XML etc. This technological integration is nothing but DHTML.

Advantages:
 DHTML is more efficient for content management purposes.
 A rich set of graphical capabilities can be implemented
 Allows for event driven programming
 DHTML results in faster and fresher content, which is more visually appealing.
 Both content and layouts can be quickly manipulated
 DHTML content loads very fast
 Support for XML
 Supports DOM (Document Object Model)

Disadvantages:
 Costly Editing tools: Although DHTML provides great functionality but the DHTML
editors available are expensive. Dreamweaver is an example of HTML editor.
 Long and Complex coding: DHTML coding is long and complex.
 Browser Support problems: DHTML suffers from browser support problems. For
example, a code written for Netscape might not work in Internet Explorer and vice-
versa.

2. Write the difference between HTML and DHTML.

HTML DHTML
HTML stands for HyperText Markup DHTML stands for Dynamic HTML

B- Com III - Web Programming


Apoorva Publishers 99
Langauge
It is an application of SGML. It is a technological integration of HTML,
VBScript, JavaScript, CSS and etc.
It is a sequential formatting language DHTML is not a language. It includes
programming through scripts and uses
DOM (Document Object Model)
This can produce only static content This can produce dynamic content
HMTL forms basis for DHTML DHTML uses HTML and depends on that.
Browse dependent Browser and Script dependent
No event handling, No validations, styles It supports event handling, validations
and styles

3. Discuss about Cascading Style Sheets (CSS) with example.

CSS: CSS stands for Cascading Style Sheets. Cascading Style Sheet (CSS) is a style sheet
language used to describe the presentation semantics (the look and formatting) of a
document written in a markup language. The common application of CSS is to style web
pages written in HTML and XHTML, but the language can also be applied to any kind of
XML document.

Syntax: CSS has a simple syntax and uses a number of English keywords to specify the
names of various style properties. A style sheet consists of a list of rules. Each rule
consists of one or more selectors and a declaration block. A declaration-block consists
of a list of declarations in braces. Each declaration itself consists of a property, a colon
(:), a value, then a semi-colon (;). The syntax is shown below.

Selector Declaration Declaration

h1 { color: blue; font-size: 12; }


Property value property value

 The selector is normally a HTML element or our own class or id we want to style.
 Each declaration consists of a property and a value.
 The property is the style attribute we want to change. Each property has a value.

Types of properties supported by CSS: The main capabilities of CSS are its support for
the following.
 Font properties such as type, size and emphasis
 Color of text, backgrounds, and other elements
 Text attributes such as spacing between words, letters, and lines of text
 Alignment of text, images, tables and other elements

B- Com III – Web Programming


100 Apoorva Publishers
 Margin, border, padding, and positioning of elements

Advantages:
 CSS can be made dynamic by using them in Scripts. With a simple change of one
line, a different style sheet can be used for the same page
 It facilitates Separation of content from presentation (styles)
 Site-wide consistency, the global style sheet can be used to affect and style
elements site-wide.
 Bandwidth, a style sheet is stored in the browser cache. Therefore, it can be used
on multiple pages without being reloaded, reducing data transfer over a network.

Disadvantages:
 Poor layout controls
 There are control limitations to place elements vertically
 We cannot use mathematical expressions in the place of values
 Lack of column declaration i.e. multiple columns are complex to implement.
 Pseudo-class (like :hover, :first-line) dynamic behavior not controllable

Example: The following program uses two HTML element selectors h1 and h2 to apply
styles on them.
<HEAD>
<TITLE>CSS Example</TITLE>
<STYLE TYPE="text/css">
H1 { font-size: x-large; color: red }
H2 { font-size: large; color: blue }
</STYLE>
</HEAD>

<body>
<h1> Hello </h1>
<h2> Apoorva </h2>
</body>

4. How many types of style sheets are existing in DHTML/CSS? Explain with an example.
(Or) Explain about (i) Style Sheets (ii) External Style Sheets (iii) Embedded Style
Sheets (iv) Inline Style Sheets.

Style Sheet: A style sheet is used to describe the presentation semantics (the look and
formatting) of a document written in a markup language. The common application of
CSS is to style web pages written in HTML and XHTML, but the style sheets can also be
applied to any kind of XML document.

B- Com III - Web Programming


Apoorva Publishers 101
Types Style Sheets: CSS allows three types of style sheets, which are discussed below.
1. Inline styles: These are written inside the HTML document, style information on a
single element, specified using the "style" attribute
2. Embedded style: These are written as blocks of CSS information inside the HTML
using <style> tag.
3. External style sheets: These are separate “.CSS” files referenced from the
document.
4. Imported Style Sheets: These are used to import “.css” files from other servers.

Note: also, refer to the following four questions.

5. Explain Inline Style Sheets with an example.

Inline styles: These are written inside the HTML document, style information on a
single element, specified using the "style" attribute

General format for inline style sheet is shown below:

<tag style="property:value [; property:value]...">


Text
</tag>

The keyword style is followed by a quoted list of style properties and associated values,
connected with colons (:) and separated by semicolons (;). For instance, to set the font
family and font size for the text contained within a paragraph, the following inline style
sheet is coded inside the opening <p> tag.

<p style="font-family:arial; font-size:9pt">


Apoorva Degree College
</p>

An inline style sheet can appear inside any tag to directly set its style. All that is
required is to enclose the applicable style properties and values inside the style
attribute.

6. Explain Embedded Style Sheets with an example.

Embedded Style Sheets: These are written as blocks of CSS information inside the
HTML using <style> tag. When a large number of style settings are used on a Web page,
we can use style settings together in one place as an embedded style sheet. An
embedded style sheet normally is coded inside the <head> section of the document
surrounded by a <style> tag. It applies styles across the entire Web page through
B- Com III – Web Programming
102 Apoorva Publishers
simple selectors, group selectors, contextual selectors, ID selectors, class selectors,
and sub-class selector whose general formats are shown below.

<head>
<style type="text/css">
tag {property:value; ...} /* Simple selector */
tag, tag,... {property:value; ...} /* Group selectors */
tag sub-tag ... {property:value; ...} /* Contextual selector */
#id {property:value; ...} /* Id selector */
.class {property:value; ...} /* Class selector */
tag.class {property:value; ...} /* sub-class Selector */
</style>
</head>

Example: The following program uses two one simple selector ‘h1’ and a class selector
“mystyle” to apply styling. Here, we have embedded the style definitions in the HTML
program using <style> tag.

<HEAD>
<TITLE>CSS Example</TITLE>
<STYLE TYPE="text/css">
h1 { font-size: x-large; color: red }
mystyle { font-size: large; color: blue }
</STYLE>
</HEAD>
<body>
<h1> Hello </h1>
<h2 class="mystyle"> Apoorva </h2>
</body>

7. Explain External (Linked) Style Sheets with an example.

External (Linked) Style Sheets: These are separate “.CSS” files referenced from the
document. The format for defining linked styles is the same as for an embedded style
sheet with the exception that a <style> tag does not enclose the specifications. The
style sheet document is saved as a simple text file, normally identified with the .css file
extension to differentiate it from .html documents.

For example, below is a set of style specifications contained within a text document
named “mysheet.css”

P {font-family:arial; font-size:10; color:black}


h1, h2 {color:blue; text-align:center}
.mystyle {font-family:arial; font-size:20}
B- Com III - Web Programming
Apoorva Publishers 103

Any HTML page can apply these style settings by linking to this mysheet.css document
with a <link> tag coded in the <head> section of the page. With this, the page can have
all the styles defined in that linked file.

<head>
<link href="mysheet.css" type="text/css" rel="stylesheet">
</head>

<body>
<h1> Hello </h1>
<p> Welcome to Apoorva </p>
<h2 class="mystyle"> Thankyou </h2>
<body>

8. Explain Imported Style Sheets with an example.

A style sheet may be imported with the @import statement. This statement may be
used in a CSS file or inside the STYLE element. This can be used to import .css files from
other directories or other servers. The following example shows importing .css files
from other server and other directory.

<STYLE TYPE="text/css" >


@import url("http://www.htmlhelp.com/style.css")
@import url("stylesheets/mystyles.css")
</STYLE>

9. Explain different types of Selectors used in style sheets.

A Selector is an id or tag, or a class associated with a set of style-properties. The


different types selectors used in CSS are shown below with their general formats.

<style type="text/css">
tag {property:value; ...} /* Simple selector */
tag, tag,... {property:value; ...} /* Group selectors */
tag sub-tag ... {property:value; ...} /* Contextual selector */
#id {property:value; ...} /* Id selector */
.class {property:value; ...} /* Class selector */
tag.class {property:value; ...} /* sub-class Selector */
tag:pseudo-class {property:value; ...} /* pseudo-class Selector */
</style>

B- Com III – Web Programming


104 Apoorva Publishers
Simple Selectors: Here, we associate styles with an existing HTML tag. In this, the
tag name is followed by a set of properties and values enclosed within braces { }. For
instance, to set the font family and size for all paragraphs (the tag <p>) in a document,
the following simple selector entry is written. And, wherever a <p> tag is encountered
in the Web document, the browser applies these styles to its content.

<style type="text/css">
p {font-family:arial; font-size:9pt}
</style>
<p> Welcome to Apoorva </p>

Group Selectors: In a similar manner, identical styles can be applied to multiple tags
by listing the tag names separated by commas. In the following example, all <h1>,
<h2>, and <h3> tags appearing on the page will have the same styling.

<style type="text/css">
h1, h2, h3 {font-family:arial; color:blue}
</style>
<h1> Welcome to Apoorva </h1>
<h2> Welcome to Apoorva </h2>
<h3> Welcome to Apoorva </h3>

Contextual Selectors: A contextual selector gives the combination of tags and sub-
tags (or nested tags) separated by spaces. For example, the contextual selector in the
example below is P EM. This rule says that emphasized text within a paragraph should
have a yellow background; <em> in other tags or <p> tag alone or <em> tag alone
would not affect the text in those tags.

<style type="text/css">
P EM { background: yellow }
</style>
<p> <em> Welcome </em> </p> <!-- displayed with yellow background -->
<p> Paragraph Text </p> <!-- displayed in its usual style -->
<em> Emphasized Text </em> <!-- displayed in its usual style -->

ID Selectors: It is recommended to use id selector on one tag only, because script


programs can identify individual elements using this id. The following example creates
an Id selector, which on used in a tag produces the specified style.

<style type="text/css">
#MyPar {font-family:arial; font-weight:bold}
</style>
<p id="MyPar"> Welcome to Apoorva </p>

B- Com III - Web Programming


Apoorva Publishers 105
Class Selectors: A general style that can be applied to any tag is known as a style
class and is defined by assigning a class name, preceded by a period (.), to its style
properties. In the following example, a class named “.mystyle” is created. This can be
used in any tag as the value of “class” attribute with in that.

<style type="text/css">
.mystyle{font-family:arial; font-size:10pt; color:blue}
</style>
<p class="mystyle"> Welcome to Apoorva </p>
<h1 class="mystyle"> Know More </h1>

Sub-Class Selectors: A simple selector can have different classes, thus allowing the
same element to have different styles. For example, we may wish to display <h1> in a
different color depending on the class value it uses in the corresponding tag.

<style type="text/css">
H1.style1 { color: red }
H1.style2 { color: blue }
</style>
<h1 class="style1"> Know More </h1>
<h1 class="style2"> Grow More </h1>

Pseudo-Class Selectors: A pseudo-class selector is used to add special effects to


some portion (or for special actions) of some selectors. For example, “hover” pseudo-
class applies the specified style when mouse moves over the element. Similarly, The
first-letter pseudo-element is used to create drop caps and other effects. Only, the first
letter of text within an assigned selector will be rendered according to the value
assigned.
<style type="text/css">
a:hover { color: red }
h1:first-letter {font-size:300%}
</style>
<a href="abc.html"> Know More </a>
<h1> welcome </h1> <!-- the first letter appears in a big size -->

10. Discuss Style Classes with an Example.

 A general style that can be applied to any tag is known as a style class and is
defined by assigning a class name, preceded by a period (.), to its style properties.
Style classes are also known as class selectors.
 One element (tag) can have only one class attribute, but the same class can be
used in many different tags.
 Style classes can be defined in embedded styles and external styles.
B- Com III – Web Programming
106 Apoorva Publishers
 In the following example, a class named “.mystyle” is created. This can be used in
any tag as the value of “class” attribute with in that.

<head>
<style type="text/css">
.mystyle{font-family:arial; font-size:10pt; color:blue}
</style>
</head>
<body>
<p class="mystyle"> Welcome to Apoorva </p>
<h1 class="mystyle"> Know More </h1>
</body>

11. Explain Text Properties in CSS (DHTML).


Property Description Possible Values Examples
color Declares the color of the Valid color names, div { color:green; }
text. RGB values, div { color:rgb(0,255,0); }
hexidecimal div { color:#00FF00; }
notation.
direction Declares the reading ltr = left-to-right div { direction:ltr; }
direction of the text. rtl = right-to-left div { direction:rtl; }
line-height Declares the distance Numbers, div { line-height:normal; }
between lines. percentages, div { line-height:2em; }
lengths. div { line-height:125%; }
letter-spacing Declares the amount of A length or ‘normal’ div { letter-spacing:normal; }
space between text div { letter-spacing:5px; }
characters. div { letter-spacing:-1px; }
text-align Declares the horizontal left, right, center, div { text-align:center; }
alignment of inline justify div { text-align:right; }
content.
text-decoration Declares the text none div { text-decoration:none; }
decoration. underline, overline, div { text-
line-through, blink decoration:underline; }
text-indent Declares the indentation Lengths and div { text-indent:12px; }
of the first line of text. percentages. div { text-indent:2%; }
text-shadow Declares shadow effects A list containg div { text-shadow:green 2px
on the text. values that specify: 2px 7px; }
(color, horizontal div { text-shadow:olive -3px -
space, vertical 4px 5px; }
space, blur radius)
text-transform Declares the capitalization None, capitalize, div { text-
effects on the letters in uppercase, transform:uppercase; }
the text. lowercase div { text-
transform:lowercase; }

B- Com III - Web Programming


Apoorva Publishers 107
white-space Declares how white space normal, pre, div { white-space:pre; }
is handled in an element. nowrap div { white-space:nowrap; }
word-spacing Declares the space between A length or normal div { word-spacing:normal; }
words in the text. div { word-spacing:1.5em; }

12. Explain Font Properties in CSS (DHTML).

Property Description Possible Values Examples


font-family Declares the name Valid font family names, i.e. div { font-family:Arial; }
of the font to be Arial, Verdana, sans-serif,
used. etc.
font-size Declares the size of Lengths (number and unit div { font-size:70%; }
the font. type— i.e. 1em, 12pt, 10px, div { font-size:0.85em; }
80%) or one of the following div { font-size:medium; }
predefined values:
xx-small, x-small, small,
medium, large, x-large, xx-
large, smaller, larger
font-style Declares the font Normal, italic, oblique div { font-style:italic; }
style. div { font-style:oblique; }
font-variant Declares the font normal, small-caps div { font-variant:normal; }
variant. div { font-variant:small-caps; }
font-weight Declares the font normal, bold, bolder, lighter div { font-weight:bolder; }
weight (lightness or or value in hundreds div { font-weight:200; }
boldness)
font Used to set all of Separate values by a space div { font:italic small-caps bold
the font properties in the following order 1em 1.2em Arial }
at once font-style, font-variant, font- div { font:bold 0.8em Verdana }
weight, font-size, line-
height, font-family

13. Explain Background Properties in CSS (DHTML).

Property Description Possible Values Examples


background-attachment Declares the fixed div { background-
attachment of scroll attachment:fixed; }
a background div { background-
image attachment:scroll; }
background-color Declares the Valid color names, div { background-color:green;
background RGB values, }
color. hexidecimal notation.
background-image Declares the URL values. div { background-
background image:url(images/img.jpg); }
image of an body { background-
element. image:url(img.jpg); }

B- Com III – Web Programming


108 Apoorva Publishers
background-position Declares the Lengths or div { background-
position of a percentages, or one of position:10px 50px; }
background the predefined values: div { background-
image top left, top center, position:bottom right; }
top right, center left,
center center, center
right, bottom left,
bottom center,
bottom right
background-repeat Declares how Repeat, repeat-x div { background-
and/or if a repeat-y, no-repeat repeat:repeat-x; }
background div { background-repeat:no-
image repeats. repeat; }
background Used to set all Separate values by a div { background:green
the background space in the following url(image.jpg) no-repeat fixed
properties at order (background- center center; }
once color, image, repeat, div { background:url(image.jpg)
attachment, position) fixed; }

14. Explain Border Properties in CSS (DHTML).

Property Description Possible Values Examples


border-top-width Declares the width of Length values, or div { border-top-
border-bottom- width the borders thin, medium,thick width:2px; }
border-left- width accordingly. div { border-left-
border-right- width * all the 4 border width:thin; }
border-width* widths at a time
border-top-color Declares the color of Valid color names, div { border-top-
border-bottom-color the borders RGB values, color:green; }
border-left-color accordingly hexidecimal notation, div { border-bottom-
border-right-color * all the 4 border or ‘transparent’ color:red; }
border-color* colors at a time
border-top-style Declares the style of None, hidden, dotted, div { border-right-
border-bottom- style the borders dashed, solid, double, style:solid; }
border-left- style accordingly. groove, ridge, inset, div { border-left-
border-right- style *All the 4 border outset style:inset; }
border-style * styles at a time
border-top Used to set width, Separate values by a div { border-top:2px solid
border-bottom style, color space in the following green; }
border-left properties at once to order div { border-left:thick
border-right the specified border Width, style, color double red; }
border Used to set width, Separate values by a div { border:1px double
style, color space in the following green; }
properties at once to order: width, style, div { border:thin solid
all the 4 borders color #00FF00; }

B- Com III - Web Programming


Apoorva Publishers 109
15. Explain Margin Properties in CSS (DHTML).

Property Description Possible Values Examples


margin-top Declares the top margin for Lengths, percentages, and div { margin-
the element. the predefined value auto. top:5px; }
margin-right Declares the right margin Lengths, percentages, and div { margin-
for the element. the predefined value auto. right:15%; }
margin-bottom Declares the bottom Lengths, percentages, and div { margin-
margin for the element. the predefined value auto. bottom:5px; }
margin-left Declares the left margin for Lengths, percentages, and div { margin-
the element. the predefined value auto. left:5px; }
margin used to declare all the Separate values by a space in div { margin:5px
margin properties at once. the following order: 12px 4px 7px; }
margin-top, margin-right, div { margin:5px
margin-bottom, margin-left 10px; }

16. Explain Positioning and Display Properties in CSS (DHTML).


Property Description Possible Values Examples
display Declares if/how the element displays. None, inline, div { display:none; }
block div { display:inline; }
list-item, and etc div { display:marker; }

float Declares whether a box should float left, right, none div { float:left; }
to the left or right of other content or div { float:right; }
not
visibility Declares the visibility of an element Visible, hidden, div { visibility:visible; }
collapse div { visibility:hidden; }
top Declares the distance between Lengths, div { top:15px; }
bottom content edge of the element and its percentages, and div { left:2%; }
right containing block accordingly the predefined
left (position should not be static) value auto.
Pixeltop Positioning values in pixels Only integer div { pixelleft:100; }
Pixelbottom values
Pixelleft
Pixelright
position Declares the type of positioning of an Static, relative, div { position:absolute; }
element absolute, fixed div { position:relative; }
z-index Declares the stack order of the Integer values or div { z-index:2; }
element. auto. div { z-index:auto; }

17. Explain Dimension Properties in CSS (DHTML).


Property Description Possible Values Examples

B- Com III – Web Programming


110 Apoorva Publishers
height Declares the height/max- Lengths, percentages, div { height:200px; }
max-height height/min-heigth of the and the predefined div { min-height:600px; }
min-height element. value auto
width Declares the width/max- Lengths, percentages, div { width:500px; }
max-width width/min-width of the element and the predefined div { max-width:75%; }
min-width value auto

18. Explain List Properties in CSS (DHTML).

Property Description Possible Values Examples


list-style-type Declares the type of disc, circle, square ol { list-style-type:upper-roman; }
list marker used. decimal and so on. ul { list-style-type:square; }
list-style-position Declares the position inside, outside ol { list-style-position:inside; }
of the list marker ul { list-style-position:outside; }
list-style-image Declares an image to URL values ul { list-style-
be used as the list image:url(image.jpg); }
marker.
list-style used to declare three Separate values by ul { list-style:disc inside
list properties at once. a space in the url(image.gif); }
following order: ol { list-style: upper-roman
list-style-type, outside; }
list-style-position,
list-style-image

19. Explain Table Properties in CSS (DHTML).


Property Description Possible Values Examples
border-collapse Declares the way borders collapse table { border-
are displayed. separate collapse:collapse; }
table { border-
collapse:separate; }
border-spacing Declares the distance Lengths for the table { border-spacing:5px; }
separating borders (if horizontal and table { border-spacing:5px
border-collapse is vertical spacing, 10px; }
separate). separated by a space.

caption-side Declares where the table top, bottom, left, caption { caption-side:top; }
caption is displayed in right caption { caption-side:right; }
relation to the table.
empty-cells Declares the way empty show, hide table { empty-cells:show; }
cells are displayed (if table { empty-cells:hide; }
border-collapse is
separate).
table-layout Declares the type of table auto, fixed table { table-layout:auto; }
layout table { table-layout:fixed; }

B- Com III - Web Programming


Apoorva Publishers 111
20. How to position the following elements using style sheet? Write a program to position
three images as shown in the figure below.

To position the images as shown in the above program, we use the CSS style property
‘position’ with ‘absolute’ as its value. When we use this option, the exact positioning
can be set using the properties left and top. The following program positions the three
images as required.

<html>
<body>
<img src="face.gif" width=100 height=100
style="position:absolute; left=0; top:0">
<img src="face.gif" width=100 height=100
style="position:absolute; left=100; top:100">
<img src="face.gif" width=100 height=100
style="position:absolute; left=200; top:200">
</body>
</html>

21. What is an Event? Explain Event handling in DHTML. (Or) Discuss about Dynamic HTML
Event Model with the help of an example.

Event: Events are various actions that take place in a program. Script can be invoked
when an associated event triggers. DHTML combined with scripts (VBScript, JavaScript)
allow for event-driven programming.
 Events can be triggered by performing specified action on different form elements
or HTML elements such as buttons, checkboxes, radio buttons, form, table and etc
 Each element may support several different events. For example, the <body> tag
supports the events like onclick, onload, onunload, onmousedown an etc.

Event Handling: Event handling is binding a function or procedure to an event, which


will be executed only when the associated event triggers. We can modify style
properties of elements dynamically using event handling.

Some of the common events possible are listed below.


B- Com III – Web Programming
112 Apoorva Publishers

Events Meaning
onclick When a mouseclick happens on an element
ondblclick When a mouse-doubleclick happens on an element
onblur When an element loses focus
onfocus When an element gets focus
onkeydown When a keyboard key is pressed
onkeyup When a key is released
onkeypress When a keyboard key is pressed or held down
onmousedown When a mouse button is held down
onmouseup When mouse button is released
onmousemove When mouse moves
onmouseout When muse cursor is moved out of the control
onmouseover When mouse moves over the control

Example: The following program changes the color of the text to blue when the mouse
moves over the text “Welcome to Apoorva” and it turns “black” when the mouse
comes out of that. It uses two events: onMouseOver and onMouseOut.

<h1 onMouseOver="style.color='blue'" onMouseOut="style.color='black'">


Welcome to Apoorva
</h1>

22. Write short notes on ONCLICK event with example.

OnClick: A click event occurs when a button, checkbox, radio button, reset button, or
submit button is clicked using left mouse button. This event is commonly used with a
button to start script execution.

Example (VBScript): In the example below, when we click on the button "Click Me" it
will execute the VBScript statement " VBScript:msgbox('U Clicked Me')" and gives the
message “U Clicked Me”.

<body>
<form>
<input type="Button" value="Click Me"
onClick="VBScript:msgbox('U Clicked Me')">
</form>
</body>

Example (DHTML with VBScript): The following program uses three button controls
with onclick event. When the buttons are clicked, the text will be aligned (left or right
B- Com III - Web Programming
Apoorva Publishers 113
or center) according to the button clicked. It uses the CSS property “textalign” to align
the text.

<script language="VBScript">
sub f1(obj)
hid.style.textalign = obj.value
end sub
</script>

<body>
<form name="frm">
<h1 id="hid"> welcome </h1>
<input type=button name="B1" value="Left"
onclick="f1(me)">
<input type=button name="B2" value="Center"
onclick="f1(me)">
<input type=button name="B3" value="Right"
onclick="f1(me)">
</form>
</body>

23. Write short notes on ONDBLCLICK event with example.

OnDblClick: A Double Click event occurs when a button, checkbox, radio button, reset
button, or submit button is double clicked.

<script language="VBScript">
sub B1_OnDblClick()
hid.style.visibility="hidden"
end sub
</script>

<body>
<form>
<h2 id="hid"> I will disappear </h2>
<input type=button value="Hide" name="B1">
</form>
</body>

B- Com III – Web Programming


114 Apoorva Publishers
In the above program, the ‘OnDblClick()’ event fires when the user double clicks the
button and the text disappears.

24. Write short notes on ONMOUSEOVER, ONMOUSEOUT events with an example.

 onMouseOver: An onMouseOver event occurs when the user positions their


mouse over a hyperlink, or a linked region of a client-side image map, or button or
any other valid element.
 onMouseOut: An onMouseOut event occurs when the user moves their mouse off
of a hyperlink, or a linked region of a client-side image map or button or any other
valid element.

Example 1: In the following example, the onMouseOver(), OnMouseOut() events are


added to the <h1> tag. When the mouse moves over the heading, the script will write a
message in the status bar of the browser window. When the mouse moves out of the
haeding, it will write thank you in the status bar.

<h1 onMouseOver="window.status='welcome to Apoorva' "


onmouseout="window.status='thank you' ">
Welcome to Apoorva
</h1>

Example 2: The following program changes the color of the text to blue when the
mouse moves over the text “Welcome to Apoorva” and it turns “black” when the
mouse comes out of that. It uses two events: onMouseOver and onMouseOut.

<script language="VBScript">
sub f1()
head1.style.color ="blue"
end sub

sub f2()
head1.style.color ="black"
end sub
</script>

<body>
<h1 id="head1" onmouseover="f1()" onmouseout="f2()">
Welcome to Apoorva
</h1>
</body>

B- Com III - Web Programming


Apoorva Publishers 115
25. Write short notes on ONMOUSEUP, ONMOUSEDOWN, ONMOUSEMOVE events with an
example.

 OnMouseDown: When a mouse button is held down, this event fires and the
associated procedure will be executed.
 OnMouseUp: When mouse button is released, this event fires and the associated
procedure will be executed.
 OnMouseMove: When the mouse moves, this event fires and the associated
procedure will be executed.

Example: The following program uses the three events: onmousedown, onmouseup
and onmousemove. It - displays the message “mousedown” when the mouse button is
held down; displays “mouseup” when we release the mouse button; displays the
mouse cursor position (x, y values) within the browser.

<script language="VBScript">
sub f1()
head1.innerHTML ="mousedown"
end sub

sub f2()
head1.innerHTML ="mouseup"
end sub

sub f3()
head1.innerHTML=window.event.clientx & "," & _
window.event.clienty
end sub
</script>

<body onmousedown="f1()" onmouseup="f2()"


onmousemove="f3()">
<h1 id="head1"> Hello Everybody </h1>
</body>

26. Explain “Mouse events” with examples.

Note: Refer to previous two questions.

27. Write short notes on ONKEYDOWN, ONKEYUP, ONKEYPRESS events with example. (Or)
Explain Keyboard related events.

B- Com III – Web Programming


116 Apoorva Publishers
 OnKeyDown: When a keyboard key is held down, this event fires and the
associated procedure will be executed.
 OnKeyUp: When a keyboard key is released, this event fires and the associated
procedure will be executed.
 OnKeyPress: When a keyboard key is pressed or held down, this event fires and
the associated procedure will be executed.

Example: The following program demonstrates the use of the three keyboard events. It
displays the character pressed and its uni-code in two text boxes when the user presses
and releases a key. It also displays a message in the window status bar.

<script language="VBScript">
sub f1()
frm.t1.value=chr(window.event.keyCode)
end sub

sub f2()
frm.t2.value=window.event.keyCode
end sub
</script>

<body onkeydown="f1()" onkeyup="f2()"


onkeypress=”window.status=’key pressed’>
<form name="frm">
<center>
Press a Key to know its UniCode Value
<br>Character:<input type=text name="t1" disabled>
<br>Uni Code:<input type=text name="t2" disabled>
</center>
</form>
</body>

28. Write short notes on ONFOCUS, ONBLUR events with an example.

onFocus: This event occurs when a control gains its input focus. A control gains a focus
when a user tabs into or clicks on elements like password, text-field, textarea, button
and so on. This indicates that a control is ready to receive input or to be clicked.

B- Com III - Web Programming


Apoorva Publishers 117
onBlur: This event fires when a control loses its input focus. For example, the blur
event triggers when the user leaves a control like a password or text or textarea. The
main difference between onblur() and onchange() is onchange() is fired only when the
content in the related control is changed. But, onblur() is fired if we just leave the
control whether the content in the related control changes or not.

Example: In the following example when the user clicks in the text box (onfocus), the
background of the text becomes light green; and when the user moves out of the text
box (onblur), the background of the text becomes white. Similarly, when the user
moves on to the button from the textbox using tab, the message ‘click me now’ will be
displayed in the status bar.

<body>
<form>
<input type=text id="t1"
onFocus="t1.style.background='lightgreen'"
onBlur="t1.style.background='white'" >
<input type=button value="OK"
onFocus="window.status='click me now'">
</form>
</body>

29. Write short notes on ONCHANGE event with example.

onChange: This event is triggered by a text box (text, file, text-area, select) being
changed, then the changes being registered by pressing ‘tab’. That is, the event fires
when the contents of the object or selection have changed.

Example: In the following example, the two text boxes display initial values ‘Ravi’ and
‘Karimnagar’; and when they are changed by the user, the program asks for
confirmation to save the new values or to revert back to default values. It uses the
event “OnChange()”.

<script language="VBScript">
sub f1()
B- Com III – Web Programming
118 Apoorva Publishers
k = msgbox ("Text Changed! Save it?", vbYesNo)
if k=vbNo then
frm.reset
end if
end sub
</script>

<body>
<form name="frm">
<h4> OnChange Event Demo </h4>
Name:<input type=text name="t1" value="Ravi"
onChange="f1()">
<br>City:<input type=text name="t2" value="Karimnagar"
onChange="f1()">
</form>
</body>

30. Write short notes on ONLOAD, ONUNLOAD events with example.

onLoad: The load event triggers when the browser finishes loading a document. This
may be used when we want to initialize values for variables or to understand the
version and type of the browser and controlling the formatting accordingly.

onUnload: This event occurs during the unloading of the page from the browser,
before any HTML elements have been destroyed. The unload event occurs when we
move to a new document by using hyperlinks or close the current document.

Example: In the following example, when the page is initially loaded, it displays a
message “welcome to my site”; and when we close the page, it displays “thanks for
visiting my site”.

<script language="VBScript">
sub f1()
msgbox "Welcome to My site"
end sub

sub f2()
msgbox "Thanks for Visiting My site"
end sub
</script>
<body onload="f1()" onunload="f2()">
<h1> This is My Site </h1>
</body>

B- Com III - Web Programming


Apoorva Publishers 119
31. Write short notes on ONSELECT event with example.

onSelect: The onselect event occurs when a user selects some text in a text field. This
attribute may be used with TextArea and Text elements.

Example: In the following program, when the user selects either by dragging the mouse
or using shift and arrow buttons, the selected text will be displayed in the second text
box.

<script language="VBScript">
sub f1()
frm.t2.value=document.selection.createRange().text
end sub
</script>

<body>
<form name="frm">
<h4> oneselect event demo </h4>
Enter a string <input type=text name="t1"
onselect="f1()">
<br>Selected Text : <input type=text name="t2">
</form>
</body>

32. Write short notes on ONSUBMIT event with example.

onSubmit: A submit event occurs when the user submits a form. This event is used
with a form and a submit button. This may initiate a data-validation script or directly
send data to server. When it initiates a script, to cancel the event i.e. to cancel
submission of data, we write “formname_onsubmit =false” in the event
function. If we want to submit the data we write “formname_onsubmit =true”
in the event function.

Example: In the following example when the user clicks on the submit button, it will
execute the function "frm_OnSubmit()". If the form the validation tests (here, name
should not be numeric), a true value is returned and the data will be passed to the

B- Com III – Web Programming


120 Apoorva Publishers
"test.asp". If the form contents do not pass the validation tests, it will not send the data
to the "test.asp" and it is going to stay in the same page.

<script language="VBScript">
function frm_OnSubmit()
s = frm.t1.Value
If IsNumeric(s) or trim(s)="" Then
msgbox "Name is not vaild"
frm_OnSubmit=false
else
msgbox "Submitting your name now"
frm_OnSubmit=true
end if
end function
</script>

<body>
<form name="frm"
action="http://localhost/myasp/test.asp">
Enter name: <input type=text name="t1">
<input type=submit>
</form>
</body>

33. Write short notes on ONRESET event with example.

Onreset: The onreset event occurs when a form is reset. It only applies to the FORM
elements. It clears the values of all the form elements or sets their default values.

Example: In the following example, after entering values in the text boxes, if the user
presses “reset” button, the program puts a confirmation whether to reset the values or
retain the values (i.e. to cancel resetting). Depending upon the user’s response it
resets the values or cancels the resetting.

<script language="VBScript">
function frm_onReset()
k = msgbox ("Reset all values?", vbYesNo)
if k=vbNo then
frm_onReset=false
else
frm_onReset=true
B- Com III - Web Programming
Apoorva Publishers 121
end if
end function
</script>

<body>
<form name="frm" >
<h4> OnReset Event Demo </h4>
Name: <input type=text name="t1">
<br>City: <input type=text name="t2">
<br> <input type=reset >
</form>
</body>

34. Write short notes on ONERROR event with example.

OnError: The onerror event is triggered when an error occurs loading a document or an
image or because of script errors. Even the syntactical errors can be monitored using
this. We can take alternate measures in the case of errors.

Example: The following program uses OnError event to capture the VBScript errors
while loading the page. The program has two error causing statements and in the
ouput, it is shown what the errors, sources and the line numbers are.

<SCRIPT language=VBScript>
set window.onerror = GetRef("Handler")
function Handler ( msg, url, line )
document.write "<BR>Error : " & msg
document.write "<BR>File : " & url
document.write "<BR>Line No : " & line
Handler=true
End function
t1.value=30 'error causing statement
</SCRIPT>
<SCRIPT language=VBScript>
document.write "Hello 'error causing statement
</SCRIPT>

Output:
Error : Object required: 't1'
File : file:///C:/test.html
Line No : 9
Error : Unterminated string constant
File : file:///C:/test.html
Line No : 13

B- Com III – Web Programming


122 Apoorva Publishers

35. Explain about the "CreateElement" method in Dynamic content. (or) How to
create elements dynamically?
CreateElement: The createElement method creates a stand-alone element under the
document object dynamically i.e. after the page is loaded using event handling. We can
create any element except frame and iframe. The HTML tag is the only parameter we
need to specify when calling the createElement. To create a <FONT> tag element, we
would write:

set fontobj = document.createElement("FONT")


After creating the element, we can specify values for the attributes of that element as
shown below.

fontobj.face ="arial"
fontobj.color ="red"
fontobj.innerHTML ="Welcome"

Then to add the element to the page, we write:

document.body.insertbefore(fontobj)

Example: The following program creates buttons dynamically after loading the page.
Each time we click the button labeled “create buttons”, it creates a new button.

Initial Display After clicking the “Create Buttons” 4 times


<SCRIPT language="VBScript">
dim i
i=1
sub createButton()
set b1 = document.createElement("Button")
b1.value ="B" & i
document.body.insertbefore(b1)
i=i+1
end sub
</SCRIPT>

<BODY>
<INPUT TYPE="BUTTON" ONCLICK="createButton()"
VALUE="Create Buttons">
</BODY>

B- Com III - Web Programming


Apoorva Publishers 123
36. Write a program to Create a table dynamically and Add/Delete rows dynamically in
DHTML.
To create a table dynamically, we use “CreateElement” method and to insert/delete
rows dynamically, we use the methods insertRow() and deleteRow() dynamically. The
following program demonstrates that. When the page is loaded “createTable()
procedure is called and it creates a table element. Then clicking on “add row” button,
generates table rows; clicking on “delete row” button deletes table rows.

After clicking “Add Row” button thrice

After clicking “Delete Row” button

<SCRIPT LANGUAGE="VBScript">
dim k,tab1
k=1

sub createTable()
set tab1= document.createElement("table")
tab1.border=1
tab1.width=300
document.body.insertbefore(tab1)
end sub

sub f1()
set r=tab1.insertRow()
for i=0 to 2
set c1 = r.insertCell()
c1.innerHTML = "data " & k
k=k+1
next
end Sub
B- Com III – Web Programming
124 Apoorva Publishers
Sub f2()
tab1.deleterow()
k=k-3
end sub
</SCRIPT>

<BODY onload="createTable()">
<form>
<INPUT TYPE="BUTTON" NAME="B1" VALUE="Add Row"
onclick="f1()">
<INPUT TYPE="BUTTON" NAME="B2" VALUE="Delete Row"
onclick="f2()">
</form>
</BODY>

37. With an example, explain how to change text, attributes, style, and graphics
dynamically.

Using DHTML (scripting, css, html) we can change the text, attributes, style and
graphics of HTML elements dynamically.

Changing Text: To change the text of an element dynamically, we use “innerHTML”


or “innerText” properties. The general syntax of using this is:

Element-id.innerHTML = “value”

Example: The following program changes the text of <h1> to “Hello World”, when we
click on the button.

<SCRIPT LANGUAGE="VBScript">
sub f1()
hid.innerHTML = "Hello World"
end sub
</SCRIPT>

<BODY>
<h1 id="hid"> Welcome </h1>
<INPUT type="button" NAME="B1" value="Change Text"
onclick="f1()">
</BODY>

Changing Attributes: To change the attribute value of an element dynamically, we


use the attribute name and set its value. The general syntax of using this is:

B- Com III - Web Programming


Apoorva Publishers 125
Element-id.attribute = “value”

Example: The following program changes the font size and color of <font> element
when we click on the button.

<SCRIPT LANGUAGE="VBScript">
sub f1()
fid.color = "blue"
fid.size = 6
end sub
</SCRIPT>

<BODY>
<font color=red size=3 id="fid"> Welcome </font> <br>
<INPUT type="button" NAME="B1" value="Change Font"
onclick="f1()">
</BODY>

Changing style: To change the style of an element dynamically, we use the


“style.property” and set its value. The general syntax of using this is:

Element-id.style.property = “value”

Example: The following program changes the color of the <h1> element and underlines
it when we click on the button.

<SCRIPT LANGUAGE="VBScript">
sub f1()
hid.style.color = "blue"
hid.style.textdecoration = "underline"
end sub
</SCRIPT>

<BODY>
<h1 id="hid"> Welcome </h1>
<INPUT type="button" NAME="B1" value="Change Style"
onclick="f1()">
</BODY>

Changing Graphics: To change the graphics(image) of <img> element dynamically,


we use “image-id.src” and set its value. The general syntax of using this is:

Image-id.src = “url of the image file”

B- Com III – Web Programming


126 Apoorva Publishers
Example: The following program changes the image of the <img> element, when we
click on the button.

<SCRIPT LANGUAGE="VBScript">
sub f1()
img1.src = "logo2.gif"
end sub
</SCRIPT>

<BODY>
<img id="img1" src="logo1.gif">
<INPUT type="button" NAME="B1" value="Change Image"
onclick="f1()">
</BODY>

38. What is a filter? What are different filters in DHTML?

Filters: Visual filters are prepackaged effects behavior that allow us to easily apply
visual effects to their content. Visual filters and transitions are currently supported
only in Microsoft Internet Explorer, but are proposed extensions to the Cascading Style
Sheet (CSS2) specification. Filters can be applied to HTML control elements through
the CSS filter property.
 For inline styles, the syntax for a filter property is:
style="filter: filtername ( parameters )"
 For embedded and linked style sheets, the syntax is:
selector { filter: filtername ( parameters ) }

Uses:
 Filters can be applied both on text and images
 They do not require much code, they can be written inline also.
 Filters can be changed dynamically.
 We can also combine filters i.e. we can apply more than one filter on one element.

Elements that can use filters: Visual filters can be applied to HTML elements that are
controls. A control element is one that defines a rectangular space within a browser
window. Valid HTML elements where filters can be applied are: BODY, BUTTON, DIV,
IMG, INPUT, MARQUEE, SPAN, TABLE, TR, TH, TD, TFOOT, THEAD, TEXTAREA.

The DIV and SPAN requires a defined height, width, or absolute position for a filter to
be applied. Filters are ignored for any positioned elements nested inside nonpositioned
elements, such as a positioned SPAN inside a nonpositioned DIV. Headings and
paragraphs, can be applied a filter if they are within a positioned DIV.

B- Com III - Web Programming


Apoorva Publishers 127
Different visual filters supported:

Filter Description
Alpha Sets the level of opacity for a visual object.
Blur Blurs an object in the specified direction and strength.
Chroma Renders a specified color in the object transparent.
Drop Shadow Creates a shadow of the object at the specified x-y offset and color.
Flip Horizontal Creates a mirror image of the visual object, horizontally.
Flip Vertical Creates a mirror image of the visual object, vertically.
Glow Gives the object the appearance of a glow.
Grayscale Renders the object in grayscale.
Invert Reverses the hue, saturation, and brightness values of the visual
object.
Light Simulates the projection of a light source onto the object.
Mask Makes a transparent mask of the visual object.
Shadow Creates a shadow around the object in the direction and color
specified.
Wave Creates a wave-like distortion of the object along its vertical axis.
XRay Transforms the visual display to monochromatic x-ray film.

Example 1: The following example demonstrates flip-filters.


<table border=1>
<tr>
<td> Normal </td>
<td> Flip Horizontal </td>
<td> Flip Vertical </td>
<td> Flip Horizontal & Vertical </td>
</tr>
<tr style="font-size=30">
<td> APOORVA </td>
<td style="filter:fliph"> APOORVA </td>
<td style="filter:flipv"> APOORVA </td>
<td style="filter:fliph flipv"> APOORVA </td>
</tr>
</table>
Output:

Example 2: The following example demonstrates other filters such as: gray, invert, xray,
wave, mask, alpha, blur, and chroma.

B- Com III – Web Programming


128 Apoorva Publishers
<table border=1>
<tr>
<td> GrayScale </td>
<td> Invert </td>
<td> X-ray </td>
<td> Wave </td>
</tr>
<tr>
<td style="filter:gray"> <img src="face.jpg"> </td>
<td style="filter:invert"> <img src="face.jpg "> </td>
<td style="filter:xray"> <img src="face.jpg "> </td>
<td style="filter:wave(strength=5)"> <img src="face.jpg">
</td>
</tr>

<tr>
<td> Mask </td>
<td> Alpha </td>
<td> Blur </td>
<td> Chroma </td>
</tr>
<tr>
<td style="filter:mask(color=red)"> <img src="face.jpg"> </td>
<td style="filter:alpha(opacity=50)"> <img src="face.jpg"> </td>
<td style="filter:blur(strength=20)"> <img src="face.jpg"> </td>
<td style="filter:chroma(color=blue)"> <img src="face.jpg"> </td>
</tr>
</table>
Output:

B- Com III - Web Programming


Apoorva Publishers 129
39. What are transitions? What are different transition filters? (Or) Discuss about the
transitions of Visual Effects with an example.

Transitions: Transitions are time-varying visual filters. Their use is to visually transition
an object from one state to the next. Two transition filters exist with Internet Explorer:
Blend Transition and Reveal Transition.

1. Blend Transition: The blend transition filter allows a simple fade-in or fade-out of
an object with a specified duration. The following example shows how to apply
the blend transition to simulate an automatic slide show between images.

Example: The following program demonstrates ‘Blend Transition’.

<script language="VBScript">
sub doTrans()
img1.filters.blendTrans.Apply()
img1.src = "face2.jpg"
img1.filters.blendTrans.Play()
end sub
</script>

<img id="img1" src="face1.jpg" width=200 height=200


style="filter:blendTrans (duration=5)"
onclick="doTrans()">

2. Reveal Transition: The reveal transition filter is a set of predefined transition


effects, such as box-in, circle-out, horizontal and vertical swipes, and so on, that
can be applied to almost any page object.

Transition Methods: Transition filters have associated methods to allow a


transition to be applied and played. The “Apply()” method freezes the visual
appearance of the control by first applying the transition. The “Play()” method
then invokes the transition. At any time, we can finish the transition by calling the
“Stop()” method.

Reveal transition uses the following syntax:


filter: revealTrans(duration=0.000, transition=0...23)

in which the ‘Duration’ is Length of time the transition and the value is expressed
in seconds.milliseconds; and ‘Transitionshape’ is the type of the transition; i.e. a
value from 0 to 23. The transition types and the values are shown in the following
table.

B- Com III – Web Programming


130 Apoorva Publishers

Transition Type Value Transition Type Value


Box in 0 Random dissolve 12
Box out 1 Split vertical in 13
Circle in 2 Split vertical out 14
Circle out 3 Split horizontal in 15
Wipe up 4 Split horizontal out 16
Wipe down 5 Strips left down 17
Wipe left 6 Strips left up 18
Wipe right 7 Strips right down 19
Vertical blinds 8 Strips right up 20
Horizontal blinds 9 Random bars horizontal 21
Checkerboard across 10 Random bars vertical 22
Checkerboard down 11 Random 23

Example: The following program demonstrates ‘Reveal Transition’.

<script language="VBScript">
sub doTrans ()
img1.filters.revealTrans.Apply()
img1.src="face2.jpg"
img1.filters.revealTrans.Play()
end sub
</script>
<img id="img1" src="face1.jpg" width=200 height=200
style="filter:revealTrans(transition=8,duration=5)">
<br><button onclick="doTrans()">Play Demo</button>

40. How Multimedia effects can be created using DHTML? (Or) Discuss about Filters and
Transitions existing in DHTML in detail.

Multimedia effects in DHTML can be created using Filters and transitions. These are
supported by Internet Explorer. Using this, one can easily develop more visually
appealing web pages with special effects without having to write much code.

Note: Also, refer to previous TWO questions.

B- Com III - Web Programming


Apoorva Publishers 131

4 ASP
1. What is ASP? What are its Features and Advantages? (Or) What is ASP?
What is the importance of ASP technology? Explain.
2. What is Server Side Programming?
3. What is ASP Script Engine? (Or) What is Server side Script Engine?
4. Explain about ASP Architecture. (Or) Explain how ASP pages really work.
5. Explain the process of serving ASP page? (Or) Write the procedure for an
Execution of ASP source code.
6. Using ASP how you will submit data to server. Give an example. Explain the
steps.
7. What are ASP Tags? How do you write ASP code? (or) What is the structure
of an ASP program?
8. Explain briefly about ASP Objects.
9. Explain “Application” object in ASP.
10. Explain “ASPError” object in ASP.
11. Explain “Request” object in ASP.
12. Explain “Response” object in ASP.
13. Explain “Server” object in ASP.
14. Explain “Session” object in ASP. (Or) What is the use of Session Object?
15. Explain the Events of Session - on Start and Session - on End.
16. Explain the object “FileSystemObject”.
17. Explain the object “TextStream” with an example.
18. Explain the object “File” with an example.
19. Explain the object “Folder” with an example.
20. Explain the object “Drive” with an example.
21. Explain the object “Dictionary” with an example.

B- Com III – Web Programming


132 Apoorva Publishers
22. Write a short notes on Data Access Technology? (Or) Write short notes on
ADO (Active X Data Object).
23. Write a short notes “Recordset” Object. (Or) Explain with an example the
importance and working with Recordset object.
24. Explain different Components in ASP.
25. Explain “AdRotator” Component with an example.
26. Explain “Browser Capabilities (BrowserType)” Component with an example.
27. Explain “Content Linking” Component with an Example.
28. Explain “Content Rotator” Component with an Example.
29. Explain “Page Counter” Component with an Example.
30. What are various ASP Objects and Components?
31. Write detailed notes on "Information Search Tools"/Index Services with
examples.
32. Write an ASP script to display Date and Time.

B- Com III - Web Programming


Apoorva Publishers 133
1. What is ASP? What are its Features and Advantages? (Or) What is ASP? What is the
importance of ASP technology? Explain.

Active Server Pages (ASP) is used to create dynamic and interactive Web pages. An ASP
page is a Hypertext Markup Language (HTML) page that contains script commands that
are processed by the Web server before sending it to the client's browser. An ASP file
can contain text, HTML tags and scripts. The scripting language can be VBScript,
JavaScript and so on.

Features of ASP:
 ASP stands for Active Server Pages
 ASP is a Microsoft Technology
 ASP is a program that runs inside IIS (IIS stands for Internet Information Services)
 ASP programs are meant for server side programming
 It is purely meant for web applications
 It supports DBMS and Active X controls
 It has so many built in objects and components.
 The asp files take the extension “.asp”.
 The default scripting language is VBScript.

Advantages of ASP (Importance of ASP technology): The importance of ASP


technology is attributed by many of its advantages, which are discussed below.
 Using ASP, we can dynamically edit, change, or add any content of a Web page
 It responds to user queries or data submitted from HTML forms
 It can access any data or databases and return the results to a browser
 We can customize a web page and make it more interactive and personal
 The advantages of using ASP instead of CGI and Perl, are those of simplicity and
speed
 It provides security - since ASP code cannot be viewed from the browser
 ASP programming can minimize the network traffic.

2. What is Server Side Programming?

Server-side programming: Server-side programming is some code that runs on the


web-server where the website is located. The resulting code is sent to the browser
(client) and displayed. Server-side programming can be encrypted when users send
form variables, ensuring more security. Some examples of server-side programming
languages are ASP, C#, VB.NET, and PHP.

Advantages:
 Server-side scripting does not have any browser limitations.

B- Com III – Web Programming


134 Apoorva Publishers
 It can produce the output irrespective of browsers.
 Server-side scripts are more secure than client-side because it can use encryption.
 Server-side scripts have greater access to the information and functions available
on the server.

Disadvantages:
 Server-side scripts require that their language's interpreter be installed on the
server.
 They create burden on the server resulting more network traffic.

Examples: Tasks done on the server side include the following.


 Keeping track of number of visitors to a website
 Database transactions
 Authorization to accessing websites
 E-mail transactions and etc

Program: The following program is simple example for server side programming that
uses ASP. The HTML file submits the name value to the server-file which in turn directs
the output to browser.

Test.asp
<%
response.write ("Hello " & _
request.querystring("t1"))
%>

Test.html
<form name="frm"
action="http://localhost/myasp/test.asp">
Name: <input type="text" name="t1" > <BR>
<input type="submit" name="submit">
</form>

3. What is ASP Script Engine? (Or) What is Server side Script Engine?

Script Engine: The script engine implements all the functions and procedures that can
be used in script programs. Without script engine, we cannot execute our script
programs.
ASP Script Engine: ASP Script engine is a server-side script engine. This is installed on
the web server and is responsible for processing ASP scripts. It is the responsibility of
ASP engine to process the ASP scripts and send the results back as HTML text to the

B- Com III - Web Programming


Apoorva Publishers 135
client. The ASP engine also invokes vbscript.dll to run VBScript scripts or JavaScript
engine to run JavaScript based scripts.

The diagram below shows how an ASP script engine works.

ASP File
Initiates
VBScript
ASP Script Engine Other Script Engines
JavaScript
Executes ASP file & Results

HTML content

4. Explain about ASP Architecture. (Or) Explain how ASP pages really work.

ASP files reside at web servers. As ASP files are meant for server side programming in
web applcations, one can access ASP files using web-clients and through web pages in a
browser.

ASP architecture constitutes the following: The running of ASP file requires the
following.
 Web server: This is where an ASP file is deployed. All the requests sent by the
clients are submitted to a web-server.
 Web Client: This is a user’s machine from which he wants to access the server to
fetch information required.
 Browser: Web applications (pages) can be viewed only in browsers. Similarly,
requesting an asp page can also be done only through browsers like Internet
Explorer.
 ASP Engine: ASP Script engine is a server-side script engine. This is installed on the
web server and is responsible for processing ASP scripts. The ASP engine also
invokes vbscript.dll to run VBScript scripts or JavaScript engine to run JavaScript
based scripts.
 Request: This is the information sent from a client to web server.
 Response: This is the information sent from a web server to a client.

Working of an ASP program: The process of the working of an ASP program is given
below.
 The web client sends a request to an ASP file using browsers.
 This request is sent to the server of the destiny

B- Com III – Web Programming


136 Apoorva Publishers
 IIS passes the request to the ASP engine. The ASP engine reads the ASP file, line by
line, and executes the scripts in the file. It may also invoke other scrip engines like
VBScript to execute related scripts.
 The server then sends the response in the form of HTML content to the client
machine.
 The HTML content is then displayed in the browser.

The architecture and working of ASP file is shown below.

file.asp
<HTML>
<BODY>
Web Server <% Response.write “<h1>” & Date() & “</h1>” %>
</BODY>
</HTML>

ASP Engine Other Scripts

Request
Response

file.asp
<HTML> Displayed in browser as
Web Client <BODY>
<h1> 10/10/2010 </h1> 10/10/2010
</BODY>
</HTML>

5. Explain the process of serving ASP page? (Or) Write the procedure for an Execution of
ASP source code.

To serve an ASP, we follow the procedure given below.

1. We first create an asp file with some asp code in that. The extension of the file
should be “.asp”. Say “test.asp”.
2. The IIS(Internet Information Server) must be installed in the computer prior to
deploying asp file.
3. We then place the asp file in a sub directory (say ‘myasp’) of “inetpub/wwwroot”.
This process is called deploying asp file in a server.
4. Now, we open the browser and type in the path to access the asp file. In a Local
machine it could be “http://localhost/myasp/test.asp”.

B- Com III - Web Programming


Apoorva Publishers 137
The execution (working) of the ASP code is explained below.

Note: Refer to the “Working of an ASP program” in the previous question.

6. Using ASP how you will submit data to server. Give an example. Explain the steps.

To submit data to a server, we usually require a HTML page with form elements or we
may also send the data in the form of manually written query strings. Sending the data
to a server and processing or manipulating the data there and have it displayed in the
client’s browser is nothing but server side programming.

When we send the data through a HTML file, it frames q query sting containing names
of the form elements and their values. A query string takes the following format.
t1=ravi&t2=33&t3=arun
Where, t1, t2 and t3 are form elements and ravi, 33 and arun are their values.

Program: Let us consider a simple HTML file with a text box. The program is an example
for server side programming which sends data to server. The HTML file submits the
name value to the server-file which in turn redirects the output to browser.

Test.asp
<%
response.write("Hello" & request.querystring("t1"))
%>

Test.html
<form name="frm" action="http://localhost/myasp/test.asp">
Name: <input type="text" name="t1" > <BR>
<input type="submit" name="submit">
</form>

The execution process when the data is submitted to a server is explained below.
Note: Refer to the “Working of an ASP program” in the question no.

7. What are ASP Tags? How do you write ASP code? (or) What is the structure of an ASP
program.

To write ASP code, we use the following tag i.e. the entire ASP code has to be put in
these tags.

Syntax:

B- Com III – Web Programming


138 Apoorva Publishers
<%
ASP code
%>

To send output to the browser, we use the following method.

response.write "some text"

The tags used in ASP are:

Tag Meaning Example


<% %> ASP code <% Response.write("hi") %>
<%= %> To print a value <% x=30 %>
<%=x%> ' prints 30
<% ' %> Comment <% ' a comment here %>
<% @ %> Directives <%@ language= "VBScript" %>

Example: The following program prints sum of two numbers.

<%
X=30
Y=40
Response.write ("Sum =" & (x+y))
%>

8. Explain briefly about ASP Objects.

Active Server Pages consist of the following seven important built in objects. They are
readymade objects, which provide functionality to the web pages.

 Application Object: Application Object describes the methods, properties, and


collections of the object that stores information related to the entire Web
application, including variables and objects that exist for the lifetime of the
application.
 ASPError Object: ASPError Object describes the properties of the object that stores
information about an error condition.
 ObjectContext Object: ObjectContext Object provides methods and events that
are used only for transaction processing.
 Request Object: Request Object describes the methods, properties, and collections
of the object that stores information related to the HTTP request. This includes
forms, cookies, server variables, and certificate data.

B- Com III - Web Programming


Apoorva Publishers 139
 Response Object: Response Object describes the methods, properties, and
collections of the object that stores information related to the server's response.
This includes printing content, manipulating headers, setting locales, and
redirecting requests.
 Server Object: Server Object describes the methods and properties of the object
that provides methods for various server tasks. With these methods we can
execute code, get error conditions, encode text strings, create objects for use by
the Web page, and map physical paths.
 Session Object: Session Object describes the methods, properties, and collections
of the object that stores information related to the user's session, including
variables and objects that exist for the lifetime of the session.

9. Explain “Application” object in ASP.

Application Object: Application Object describes the methods, properties, and


collections of the object that stores information related to the entire Web application,
including variables and objects that exist for the lifetime of the application.

An application may consist of several ASP files that work together to perform some
purpose. The Application object is used to tie these files together. The Application
object holds information that will be used by many pages in the application. The
information can be accessed from any page. The information can also be changed in
one place, and the changes will automatically be reflected on all pages. The Application
object's collections, methods, and events are described below:

COLLECTIONS
Collection Description
Contents Contains all the items appended to the application through a script
command
StaticObjects Contains all the objects appended to the application with the HTML
<object> tag

METHODS
Method Description
Contents.Remove Deletes an item from the Contents collection
Contents.RemoveAll() Deletes all items from the Contents collection
Lock Prevents other users from modifying the variables
Unlock Enables other users to modify the variables

EVENTS

B- Com III – Web Programming


140 Apoorva Publishers
Event Description
Application_OnEnd Occurs when all user sessions are over, and the application
ends
Application_OnStart Occurs before the first new session is created (when the
Application object is first referenced)

Example: The following program demonstrates the use of “Application” object. It sets
three application wide variables and uses “remove()” method.

<%
Application("Author")="Venu"
Application("Year")= "2010"
Application("Subject")="WebTech"
Application.Contents.Remove(2)
for each x in Application.Contents
Response.Write(x & "=" & Application.Contents(x)&"<br>")
next
%>

Output:
Author=Venu
Subject=WebTech

10. Explain “ASPError” object in ASP.

ASPError Object: ASPError Object describes the properties of the object that stores
information about an error condition. This object is used to display detailed
information of any error that occurs in scripts in an ASP page. The ASPError object's
properties are described below.

Property Description
ASPCode Returns an error code generated by IIS
ASPDescription Returns a detailed description of the error
Category Returns the source of the error
Column Returns the column position within the file that generated the error
Description Returns a short description of the error
File Returns the name of the ASP file that generated the error
Line Returns the line number where the error was detected
Number Returns the standard COM error code for the error
Source Returns the actual source code of the line where the error occurred

B- Com III - Web Programming


Apoorva Publishers 141
Example: The following program demonstrates the use of “ASPError” object. The
program prints the details (number, description, file, line and source) of the last errors
occurred.

<%
dim objErr
set objErr=Server.GetLastError()
response.write("<BR>Number=" & objErr.Number)
response.write("<BR>Description=" & objErr.Description)
response.write("<BR>File=" & objErr.File)
response.write("<BR>Line=" & objErr.Line)
response.write("<BR>Source=" & objErr.Source)
%>

11. Explain “Request” object in ASP.

Request Object: Request Object describes the methods, properties, and collections of
the object that stores information related to the HTTP request. This includes forms,
cookies, server variables, and certificate data.

When a browser asks for a page from a server, it is called a request. The Request object
is used to get information from a visitor. Its collections, properties, and methods are
described below:

COLLECTIONS
Collection Description
ClientCertificate Contains all the field values stored in the client certificate
Cookies Contains all the cookie values sent in a HTTP request
Form Contains all the form (input) values from a form that uses the
post method
QueryString Contains all the variable values in a HTTP query string
ServerVariables Contains all the server variable values

PROPERTIES/METHODS:
Method Description
TotalBytes Returns the total number of bytes the client sent in the body of the
(property) request
BinaryRead Retrieves the data sent to the server from the client as part of a
post request and stores it in a safe array

Example: The following program demonstrates the use of “Request” object. The
program prints the values of “fruit” and “flower” obtained through a query string. Here
B- Com III – Web Programming
142 Apoorva Publishers
we can pass the query string manually when executing the asp file as shown below.

http://localhost/myasp/test.asp?fruit=Apple&flower=Rose
Test.asp
<%
Response.Write "Fruit =" & Request.QueryString("fruit")
Response.Write "<br>Flower =" &
Request.QueryString("flower")
%>

Output:
Fruit=Apple
Flower=Rose

12. Explain “Response” object in ASP.

Response Object: Response Object describes the methods, properties, and collections
of the object that stores information related to the server's response. This includes
printing content, manipulating headers, setting locales, and redirecting requests. It is
used to send output to the user from the server. Its collections, properties, and
methods are described below:

COLLECTIONS
Collection Description
Cookies Sets a cookie value. If the cookie does not exist, it will be created.

PROPERTIES
Property Description
Buffer Specifies whether to buffer the page output or not
CacheControl Sets whether a proxy server can cache the output or not
Charset Appends the name of a character-set to the content-type
header in the Response object
ContentType Sets the HTTP content type for the Response object
Expires Sets how long (in minutes) a page will be cached on a browser
before it expires
ExpiresAbsolute Sets a date and time when a page cached on a browser will
expire
IsClientConnected Indicates if the client has disconnected from the server
Pics Appends a value to the PICS label response header
Status Specifies the value of the status line returned by the server

B- Com III - Web Programming


Apoorva Publishers 143
METHODS
Method Description
AddHeader Adds a new HTTP header and a value to the HTTP response
AppendToLog Adds a string to the end of the server log entry
BinaryWrite Writes data directly to the output in binary mode
Clear Clears any buffered HTML output
End Stops processing a script, and returns the current result
Flush Sends buffered HTML output immediately
Redirect Redirects the user to a different URL
Write Writes a specified string to the output

Example: The following program demonstrates the use of “Response” object. The
program sets a cookie value in a program, and accesses it another program.

Test1.asp
<%
Response.Cookies("firstname")="Kiran"
Response.write("Cookie has been created")
%>

Test2.asp
<%
fname=Request.Cookies("firstname")
Response.write("Firstname=" & fname)
%>

Output:
Firstname=Kiran

13. Explain “Server” object in ASP.

Server Object: Server Object describes the methods and properties of the object that
provides methods for various server tasks. With these methods we can execute code,
get error conditions, encode text strings, create objects for use by the Web page, and
map physical paths. Its properties and methods are described below:

PROPERTIES
Property Description
ScriptTimeout Sets or returns the maximum number of seconds a script can run
before it is terminated

METHODS
B- Com III – Web Programming
144 Apoorva Publishers
Method Description
CreateObject Creates an instance of an object
Execute Executes an ASP file from inside another ASP file
GetLastError() Returns an ASPError object that describes the error condition
HTMLEncode Applies HTML encoding to a specified string
MapPath Maps a specified path to a physical path
Transfer Transfers all the information created in one ASP file to another
URLEncode Applies URL encoding rules to a specified string

Example: The following program demonstrates the use of “Server” object. The program
executes a second asp file (“file2.asp”) using “execute” method from “file1.asp”.

File1.asp:
<%
response.write("I am in File 1<br >")
Server.Execute("file2.asp")
response.write("I am back in File 1")
%>

File2.asp:
<%
response.write("I am in File 2<br>")
%>

Output:
I am in File 1
I am in File 2
I am back in File 1

14. Explain “Session” object in ASP. (Or) What is the use of Session Object?

Session Object: Session Object describes the methods, properties, and collections of
the object that stores information related to the user's session, including variables and
objects that exist for the lifetime of the session.

A session is the time elapsed between opening and closing of a web application by a
user. Sessions are unique to users. ASP creates a unique cookie for each user. The
cookie is sent to the user's computer and it contains information that identifies the
user. This interface is called the Session object.

Variables stored in a Session object hold information about one single user, and are
available to all pages in one application. Common information stored in session
variables are name, id, and preferences. The server creates a new Session object for
B- Com III - Web Programming
Apoorva Publishers 145
each new user, and destroys the Session object when the session expires. The Session
object's collections, properties, methods, and events are described below:

COLLECTIONS
Collection Description
Contents Contains all the items appended to the session through a
script command
StaticObjects Contains all the objects appended to the session with the
HTML <object> tag

PROPERTIES
Property Description
CodePage Specifies the character set that will be used when displaying
dynamic content
LCID Sets or returns an integer that specifies a location or region.
SessionID Returns a unique id for each user. The unique id is generated
by the server
Timeout Sets or returns the timeout period (in minutes) for the
Session object in that application

METHODS
Method Description
Abandon Destroys a user session
Contents.Remove Deletes an item from the Contents collection
Contents.RemoveAll() Deletes all items from the Contents collection
EVENTS
Event Description
Session_OnEnd Occurs when a session ends
Session_OnStart Occurs when a session starts

Example: The following program demonstrates the use of “Session” object. The
program sets two session variables and prints all the contents of the session.

<%
Session("name")="Ramu"
Session("date")="10/10/2010"

for each x in Session.Contents


Response.Write(x & "=" & Session.Contents(x) & "<br>")
next
%>

B- Com III – Web Programming


146 Apoorva Publishers
Output:
name=Ramu
date=10/10/2010

15. Explain the Events of Session - on Start and Session - on End.

A session is the time elapsed between opening and closing of a web application by a
user. Sessions are unique to users. ASP creates a unique cookie for each user which
contains information that identifies the user. This interface is called the Session object.

Session object in asp provides two events: Session_OnStart and Session_OnEnd. They
define the task to be done when a session starts and ends respectively. These events
are placed in the “Global.asa” file.
 Session_OnStart Event: The Session_OnStart event occurs when the server creates
a session.
 Session_OnEnd Event: The Session_OnEnd event occurs when the session ends
(abandoned or times out).

Syntax: Following is the general syntax used to write the above events in “global.asa”
file.
<script language="vbscript" runat="server">
Sub Session_OnStart
. . .
End Sub
Sub Session_OnEnd
. . .
End Sub
</script>

Example: The following program uses the two session events: Session_OnStart and
Session_OnEnd. This code should be written in the file “global.asa”. The second
program is used to print the number of visitors online.

<script language="vbscript" runat="server">


Sub Application_OnStart
Application("visitors")=0
End Sub

Sub Session_OnStart
Application.Lock
Application("visitors")=Application("visitors")+1
Application.UnLock
End Sub

B- Com III - Web Programming


Apoorva Publishers 147
Sub Session_OnEnd
Application.Lock
Application("visitors")=Application("visitors")-1
Application.UnLock
End Sub
</script>

To display the number of current visitors in an ASP file, we write:

<%
response.write("No. of Online Visitors: " & _
Application("visitors"))
%>

16. Explain the object “FileSystemObject”.

FileSystemObject: The FileSystemObject is used to access the file system on a server.


This object can manipulate files, folders, and directory paths. It is also possible to
retrieve file system information with this object.
 FSOs also allow the programmer to read and write text to sequential files.
 FSOs provide the programmer with power and flexibility for working with files,
folders and drives.
 FSOs are objects in the Microsoft Scripting Library.
 FileSystemObject yields other objects like “File”, “Folder”, “Drive” and
“TextStream”.

The FileSystemObject object's properties and methods are described below:


Method Description
CopyFile Copies one or more files from one location to another
CopyFolder Copies one or more folders from one location to another
CreateFolder Creates a new folder
CreateTextFile Creates a text file and returns a TextStream object
DeleteFile Deletes one or more specified files
DeleteFolder Deletes one or more specified folders
DriveExists Checks if a specified drive exists
FileExists Checks if a specified file exists
FolderExists Checks if a specified folder exists
GetAbsolutePathName Returns the complete path from the root of the drive
GetBaseName Returns the base name of a specified file or folder
GetDrive Returns a Drive object of a specified path
GetDriveName Returns the drive name of a specified path
GetExtensionName Returns the file extension name
B- Com III – Web Programming
148 Apoorva Publishers
GetFile Returns a File object for a specified path
GetFileName Returns the file name or folder name
GetFolder Returns a Folder object for a specified path
GetParentFolderName Returns the name of the parent folder
MoveFile Moves one or more files from one location to another
MoveFolder Moves one or more folders from one location to another
OpenTextFile Opens a file and returns a TextStream object
Drives (property) Returns a collection of all Drive objects on the computer

Example: The following code uses FileSystemObject and creates a text file (c:\test.txt)
and then writes some text to the file.
<%
dim fs,fname
set fs=Server.CreateObject("Scripting.FileSystemObject")
set fname=fs.CreateTextFile("d:\test.txt",true)
fname.WriteLine("Hello World!")
fname.Close
set fname=nothing
set fs=nothing
%>

17. Explain the object “TextStream” with an example.

The TextStream Object: The TextStream object is used to access the contents of text
files. To create an instance of the TextStream object we can use the CreateTextFile or
OpenTextFile methods of the FileSystemObject object, or we can use the
OpenAsTextStream method of the File object. The TextStream object's properties and
methods are described below:

PROPERTIES
Property Description
AtEndOfLine Returns true if the file pointer is positioned at the end-of-line
marker in a TextStream file, and false if not
AtEndOfStream Returns true if the file pointer is at the end of a TextStream file,
and false if not
Column Returns the column number of the current character position in
an input stream
Line Returns the current line number in a TextStream file

METHODS
Method Description
Close Closes an open TextStream file
B- Com III - Web Programming
Apoorva Publishers 149
Read Reads a specified number of characters from a TextStream file
ReadAll Reads an entire TextStream file and returns the result
ReadLine Reads one line from a TextStream file and returns the result
Skip Skips a specified number of characters when reading
SkipLine Skips the next line when reading a TextStream file
Write Writes a specified text to a TextStream file
WriteLine Writes a specified text and a new-line character into a file
WriteBlankLines Writes a specified number of new-line character into a file

Example: The following code creates a text file (c:\test.txt) and then writes some text
to the file and also reads the first line and prints it.
<%
dim fs,f,t,x
set fs=Server.CreateObject("Scripting.FileSystemObject")
set f=fs.CreateTextFile("d:\test.txt")
f.writeline("Hello")
f.writeline("Welcome")
f.writeline("Bye")
f.close
set t=fs.OpenTextFile("d:\test.txt",1,false)
x=t.ReadLine
t.close
Response.Write("The first line in the file is:" & x)
%>

Output:
The first line in the file is: Welcome

18. Explain the object “File” with an example.

The File Object: The File object is used to return information about a specified file. To
work with the properties and methods of the File object, we will have to create an
instance of the File object through the FileSystemObject object. First; create a
FileSystemObject object and then instantiate the File object through the GetFile
method of the FileSystemObject object or through the Files property of the Folder
object. The File object's properties and methods are described below:

PROPERTIES
Property Description
Attributes Sets or returns the attributes of a specified file
DateCreated Returns the date and time when a specified file was created
DateLastAccessed Returns the date and time when a specified file was last accessed

B- Com III – Web Programming


150 Apoorva Publishers
DateLastModified Returns the date and time when a specified file was last modified
Drive Returns the drive letter of the drive where a specified file
Name Sets or returns the name of a specified file
ParentFolder Returns the folder object for the parent of the specified file
Path Returns the path for a specified file
ShortName Returns the short name of a specified file
ShortPath Returns the short path of a specified file
Size Returns the size, in bytes, of a specified file
Type Returns the type of a specified file

METHODS
Method Description
Copy Copies a specified file from one location to another
Delete Deletes a specified file
Move Moves a specified file from one location to another
OpenAsTextStream Opens a specified file and returns a TextStream object

Example: The following code uses the GetFile method of the FileSystemObject object
to instantiate the File object and prints the size, datecreated, path, name, and drive of
the file.
<%
Dim fs,f
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set f=fs.GetFile("d:\test.txt")
Response.Write("<br>File created: " & f.DateCreated)
Response.Write("<br>File size: " & f.size)
Response.Write("<br>File path: " & f.path)
Response.Write("<br>File name: " & f.name)
Response.Write("<br>File drive: " & f.drive)
set f=nothing
set fs=nothing
%>

Output(sample):
File created: 12/4/2010 5:08:59 PM
File size: 1022
File path: C:\test.txt
File name: test.txt
File drive: c:

19. Explain the object “Folder” with an example.

B- Com III - Web Programming


Apoorva Publishers 151
The Folder Object: The Folder object is used to return information about a specified
folder. To work with the properties and methods of the Folder object, we will have to
create an instance of the Folder object through the FileSystemObject object. First;
create a FileSystemObject object and then instantiate the Folder object through the
GetFolder method of the FileSystemObject object.

The Folder object's collections, properties, and methods are described below:
COLLECTIONS
Collection Description
Files Returns a collection of all the files in a specified folder
SubFolders Returns a collection of all subfolders in a specified folder

PROPERTIES
Property Description
Attributes Sets or returns the attributes of a specified folder
DateCreated Returns the date and time when a specified folder was created
DateLastAccessed Returns the date and time when a specified folder was last
accessed
DateLastModified Returns the date and time when a specified folder was last
modified
Drive Returns the drive letter of the drive where the specified folder
resides
IsRootFolder Returns true if a folder is the root folder and false if not
Name Sets or returns the name of a specified folder
ParentFolder Returns the parent folder of a specified folder
Path Returns the path for a specified folder
ShortName Returns the short name of a specified folder
ShortPath Returns the short path of a specified folder
Size Returns the size of a specified folder
Type Returns the type of a specified folder

METHODS
Method Description
Copy Copies a specified folder from one location to another
Delete Deletes a specified folder
Move Moves a specified folder from one location to another
CreateTextFile Creates a new text file in the specified folder and returns a
TextStream object to access the file

B- Com III – Web Programming


152 Apoorva Publishers
Example: The following code uses the GetFolder method of the FileSystemObject
object to instantiate the Folder object and the DateCreated property to return the date
when the specified folder was created:
<%
Dim fs,fo
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set fo=fs.GetFolder("d:\test")
Response.Write("Folder created: " & fo.DateCreated)
set fo=nothing
set fs=nothing
%>

Output (sample):
Folder created: 10/10/2010 10:05:20 AM

20. Explain the object “Drive” with an example.

The Drive Object: The Drive object is used to return information about a local disk drive
or a network share. The Drive object can return information about a drive's type of file
system, free space, serial number, volume name, and more.
To work with the properties of the Drive object, we will have to create an instance
of the Drive object through the FileSystemObject object. First, create a
FileSystemObject object and then instantiate the Drive object through the GetDrive
method or the Drives property of the FileSystemObject object. The Drive object's
properties are described below:

PROPERTIES
Property Description
AvailableSpace Returns the amount of available space on a given drive
DriveLetter Returns one uppercase letter that identifies the local drive
DriveType Returns the type of a specified drive
FileSystem Returns the file system in use for a specified drive
FreeSpace Returns the amount of free space to a user on a specified drive
IsReady Returns true if the specified drive is ready and false if not
Path Returns an uppercase letter followed by a colon that indicates the
path name for a specified drive
RootFolder Returns a Folder object that represents the root folder of a
specified drive
SerialNumber Returns the serial number of a specified drive
ShareName Returns the network share name for a specified drive
TotalSize Returns the total size of a specified drive or network share
VolumeName Sets or returns the volume name of a specified drive
B- Com III - Web Programming
Apoorva Publishers 153
Example: The following code uses the GetDrive method of the FileSystemObject object
to instantiate the Drive object and the TotalSize property to return the total size in
bytes.
<%
dim fs,d
set fs=Server.CreateObject("Scripting.FileSystemObject")
set d=fs.GetDrive("c:")
Response.Write("The total size in bytes is: " & _
d.TotalSize)
set d=nothing
set fs=nothing
%>
Output (sample):
The total size in bytes is: 4293563392
21. Explain the object “Dictionary” with an example.

The Dictionary Object: The Dictionary object is used to store information in


name/value pairs (referred to as key and item). In a Dictionary object, each item is
associated with a unique key. The key is used to retrieve an individual item and is
usually a integer or a string, but can be anything except an array. The Dictionary
object's properties and methods are described below:

PROPERTIES
Property Description
CompareMode Sets or returns the comparison mode for comparing keys in a
Dictionary object
Count Returns the number of key/item pairs in a Dictionary object
Item Sets or returns the value of an item in a Dictionary object
Key Sets a new key value for an existing key value in a Dictionary object

METHODS
Method Description
Add Adds a new key/item pair to a Dictionary object
Exists Returns a Boolean value that indicates whether a specified key exists in
the Dictionary object
Items Returns an array of all the items in a Dictionary object
Keys Returns an array of all the keys in a Dictionary object
Remove Removes one specified key/item pair from the Dictionary object
RemoveAll Removes all the key/item pairs in the Dictionary object

Example: The following example creates a Dictionary object, adds some key/item pairs
to it, and retrieves the item value for the key ‘gr’:
B- Com III – Web Programming
154 Apoorva Publishers
<%
Dim d
Set d=Server.CreateObject("Scripting.Dictionary")
d.Add "INR","Indian Rupee"
d.Add "USD","United Sates Dollar"
d.Add "GBP","Great British Pound"
d.Add "BDT","Bangladesh Taka"
Response.Write("The Full Currency Name for INR is:" & _
d.Item("INR"))
%>
Output:
The Full Currency Name for INR is: Indian Rupee

22. Write short notes on Data Access Technology? (Or) Write short notes on ADO (Active X
Data Object).

Data Access Technology: Data Access Technology in ASP pages facilitates working with
databases (creating, manipulating, and retrieving). To achieve this, we use ADO i.e.
ADO can be used to access databases from the web pages. The features of ADO are
listed below.
 ADO stands for ActiveX Data Objects
 ADO is a Microsoft Active-X component
 ADO is automatically installed with Microsoft IIS
 ADO is a programming interface to access data in a database

Accessing a Database from an ASP Page: The common way to access a database from
inside an ASP page is to:
1. Create an ADO connection to a database
2. Open the database connection
3. Create an ADO recordset
4. Open the recordset
5. Extract the data needed from the recordset
6. Close the recordset
7. Close the connection

Example: The following example uses “ADODB.connection” object and creates a table
named “student” in oracle. To connect to oracle we have used oracle DSN.

<%
set con=server.createObject(“ADODB.Connection”)
con.open “dsn=oradsn;uid=scott;pwd=tiger”
s=”create table student(rno number, sname varchar2(20))”

B- Com III - Web Programming


Apoorva Publishers 155
con.execute s
response.write “<h1> Table Created </h1>”
con.close
%>

23. Write a short notes “Recordset” Object. (Or) Explain with an example the importance
and working with Recordset object.

Recordset Object: The ADO Recordset object is used to hold a set of records from a
database table. A Recordset object consist of records and fields. In ADO, this object is
the one used most often to manipulate data from a database. ADO Recordset object
can be created using “CreateObject()” method of Server object or the object can be
returned by “execute” method of Connection object.

The syntax used to create the Recordset object is shown below.


Set rs = Server.CreateObject(“ADODB.recordset”)

Some of the commonly used properties and methods of Recordset object are listed
below.

PROPERTIES
Property Description
AbsolutePosition Sets or returns a value that specifies the ordinal position of the
current record
BOF Returns true if the current record position is before the first
record, otherwise false
Bookmark Sets or returns a bookmark. The bookmark saves the position of
the current record
DataSource Specifies an object containing data to be represented as a
Recordset object
EOF Returns true if the current record position is after the last
record, otherwise false
RecordCount Returns the number of records in a Recordset object
Sort Sets or returns the field names in the Recordset to sort on

METHODS
Method Description
AddNew Creates a new record
Close Closes a Recordset
Delete Deletes a record or a group of records
GetRows Copies multiple records from a Recordset object into a two-
dimensional array
B- Com III – Web Programming
156 Apoorva Publishers
Move Moves the record pointer in a Recordset object
MoveFirst Moves the record pointer to the first record
MoveLast Moves the record pointer to the last record
MoveNext Moves the record pointer to the next record
MovePrevious Moves the record pointer to the previous record
Open Opens a database element ( a table or the results of a query)
Save Saves a Recordset object to a file or a Stream object
Update Saves all changes made to a single record

Example: The following program uses “ADODB.connection” and "ADODB.recordset"


object. It fetches manager records from EMP table using “open” method of Recordset
object.

<%
set con=server.createObject("ADODB.Connection")
set rs = Server.CreateObject("ADODB.recordset")
con.open "dsn=oradsn;uid=scott;pwd=tiger"
rs.open "select empno, ename, job from emp where
job='MANAGER'",con
while not rs.eof
response.write "<br>" & rs("empno") & " " & rs("ename")_
& " " & rs("job")
rs.movenext
wend
rs.close
con.close
%>

Output:
7566 JONES MANAGER
7698 BLAKE MANAGER
7782 CLARK MANAGER

24. Explain different Components in ASP.

ASP Components are the built-in components that enhance the functionality of the
web pages. The different components are explained below.

 AdRotator Component: The ASP AdRotator component creates an AdRotator


object that displays a different image (banner) each time a user enters or refreshes
a page.

B- Com III - Web Programming


Apoorva Publishers 157
 Browser Capabilities Component: The ASP Browser Capabilities component
creates a BrowserType object that determines the type, capabilities and version
number of a visitor's browser.
 Content Linking Component: The ASP Content Linking component is used to create
a quick and easy navigation system. The Content Linking component returns a
Nextlink object that is used to hold a list of Web pages to be navigated.
 Content Rotator Component: The ASP Content Rotator component creates a
ContentRotator object that displays a different content strings each time a visitor
enters or refreshes a page. The strings can be links or images or simple text (like a
daily quote).
 PageCounter Component: The ASP PageCounter component is used to count
number of hits made to a web site or a page. Each time a user refreshes the page
or a new user accesses the page, the pagecount value increments.

25. Explain “AdRotator” Component with an example.

AdRotator Component: The ASP AdRotator component creates an AdRotator object


that displays a different image each time a user enters or refreshes a page. To make
this work we usually require three (sometimes two) files.
1. A text (.txt) file containing information about banners to be displayed. This
text file contains the following in order:
 Redirect URL: Clicking on the banners take us to this file to which URL
value of individual ad is sent in the form of query string.
 Width, height, border: (may be omitted to have default values)
 Image URL: Image (usually .jpg or .gif) to be displayed in the banner
 Ad URL: This is the URL value sent to the file specified in “Redirect URL”
 Alt Text: Displayed as alt text
 Percentage: Display rate in percentages.
2. An ASP (.asp) file in which banners have to be displayed. This is where we
create the AdRotator component and use GetAdvertisement function.
3. A file in which we collect Ad URL value, which is again used to redirect it to
that Ad URL. (this can be written in the same file created in step 2, thus
reducing number of files to two)

The properties and methods of AdRotator component are listed below.

Property/Method Description
GetAdvertisement Returns HTML that displays the advertisement in the page
(method)
Border Specifies the border for the advertisement
B- Com III – Web Programming
158 Apoorva Publishers
Clickable Specifies whether the advertisement is a hyperlink
TargetFrame Name of the frame to display the advertisement

Example: Following are the two files: 1. “advt.txt” A text file containing banner
information and 2. “banners.asp” used to display banners and also for redirecting
when banners are clicked.
Advt.txt
REDIRECT banners.asp
*
apoorva.jpg
http://www.apoorvacollege.com
College with a difference
50
brain.jpg
http://www.winningbrains.com
Soft Skills made easy
50
Banners.asp
<%
url=Request.QueryString("url")
If url<>"" then Response.Redirect(url)
set adrotator=Server.CreateObject("MSWC.AdRotator")
response.write(adrotator.GetAdvertisement("advt.txt"))
%>

26. Explain “Browser Capabilities (BrowserType)” Component with an example.


Browser Capabilities Component: The ASP Browser Capabilities component creates a
BrowserType object that determines the type, capabilities and version number of a
visitor's browser. The following syntax is used to create Browser capabilities
component.

<%
Set MyBrow=Server.CreateObject("MSWC.BrowserType")
%>

Example: The example below creates a BrowserType object in an ASP file, and displays
some of the capabilities of the browser in use:

<html>
<body>
<%
Set MyBrow=Server.CreateObject("MSWC.BrowserType")
%>
B- Com III - Web Programming
Apoorva Publishers 159
<br>Client OS : <%=MyBrow.platform%>
<br>Web Browser : <%=MyBrow.browser%>
<br>Browser version : <%=MyBrow.version%>
<br>Frame support? : <%=MyBrow.frames%>
<br>Table support? : <%=MyBrow.tables%>
<br>Sound support? : <%=MyBrow.backgroundsounds%>
<br>Cookies support? : <%=MyBrow.cookies%>
<br>VBScript support? : <%=MyBrow.vbscript%>
<br>JavaScript support? : <%=MyBrow.javascript%>
</body>
</html>

Example:
Client OS : WinNT
Web Browser : IE
Browser version : 5.0
Frame support? : True
Table support? : True
Sound support? : True
Cookies support? : True
VBScript support? : True
JavaScript support? : True

27. Explain “Content Linking” Component with an Example.

Content Linking Component: The ASP Content Linking component is used to create a
quick and easy navigation system. The Content Linking component returns a Nextlink
object that is used to hold a list of Web pages to be navigated. The following syntax is
used to create Content Linking component.
<%
Set nl=Server.CreateObject("MSWC.NextLink")
%>

To make this component work, we require the following files:


 A text file that contains the pages to be navigated. The pages must be listed in the
same order we want them to be displayed, and it must also contain a description
for each file name separated by tab.
Links.txt
File1.asp Apoorva Intro
File2.asp Apoorva Placements
File3.asp Apoorva Profile

B- Com III – Web Programming


160 Apoorva Publishers
 Then we create an include file, "nlcode.inc". The .inc file creates a NextLink object
to navigate between the pages listed in "links.txt". The “nlcode.inc” might have the
following code.
nlcode.inc:
<%
dim nl
Set nl=Server.CreateObject("MSWC.NextLink")
prv= nl.GetPreviousURL("links.txt")
nxt= nl.GetNextURL("links.txt")

if (nl.GetListIndex("links.txt")>1) then
Response.Write("<br><a href='" & prv)
Response.Write("'>Previous Page</a><br>")
end if
Response.Write("<br><a href='" & nxt)
Response.Write("'>Next Page</a><br>")
%>
 Then we create the files: File1.asp, File2.asp, and File3.asp and so on i.e. the files
listed in “links.txt”. In each of the .asp pages listed in the text file "links.txt", we
need to put the one line of code: <!-- #include file="nlcode.inc"--> and the
navigation will automatically work. For example the file “File1.asp” might have the
following code. Similarly all the other files.
File1.asp:
<!-- #include file="nlcode.inc"-->
<% response.write("First File Contents") %>

Following are the Methods of Content Linking Component:

Method Description
GetListCount Returns the number of items listed in the List file
GetListIndex Returns the index number of the current item in the List file.
GetNextDescription Returns the text description of the next item listed in the List file.
GetNextURL Returns the URL of the next item listed in the List file.
GetNthDescription Returns the description of the Nth page listed in the List file
GetNthURL Returns the URL of the Nth page listed in the List file
GetPreviousDescription Returns the text description of the previous item listed in the List file
GetPreviousURL Returns the URL of the previous item listed in the List file.

28. Explain “Content Rotator” Component with an Example.

Content Rotator Component: The ASP Content Rotator component creates a


ContentRotator object that displays a different content strings each time a visitor

B- Com III - Web Programming


Apoorva Publishers 161
enters or refreshes a page. The strings can be links or images or simple text (like a daily
quote). The following syntax is used to create Content Rotator component.
<%
Set cr=Server.CreateObject("MSWC.ContentRotator")
%>

To make this component work, we require the following files:


 A text file, called the Content Schedule File, includes the information about the
content strings. We write ‘#number’ at the beginning of each content string. This
number is an optional parameter that indicates the relative weight of the HTML
content string.
ads.txt
%% #3
<a href="http://www.winningbrains.com">SoftSkills</a>

%% #3
<img src="apoorva.gif">

%% #4
<a href="http://www.apoorvacollege.com">Visit Apoorva</a>

 An ASP file that creates Content Rotator component and makes use of it. The
following is an example for that.
<%
set cr=server.createobject("MSWC.ContentRotator")
response.write(cr.ChooseContent("ads.txt"))
%>

Following are the Methods of Content Rotator Component:


Method Description
ChooseContent Gets and displays a content string
GetAllContent Retrieves and displays all of the content strings in the text file

29. Explain “Page Counter” Component with an Example.

PageCounter Component: The ASP PageCounter component is used to count number


of hits made to a web site or a page. Each time a user refreshes the page or a new user
accesses the page, the pagecount value increments. The following syntax is used to
create PageCounter component.

<%
Set pc = Server.CreateObject("MSWC.PageCounter")
%>

B- Com III – Web Programming


162 Apoorva Publishers
Following are the Methods of Page Counter Component:

Method Description
Hits(url) Returns the number of hits for a specified URL
Resest(url) Resets the page counter
Pagehit() Returns number of hits as a long integer

Example: The example below creates a PageCounter component in an ASP file, and
displays the number of hits to that page.

<%
Set pc = Server.CreateObject("MSWC.PageCounter")
response.write ("No of Hits = " & pc.PageHit())
%>

30. What are various ASP Objects and Components?

Note: Refer to question no: 8 and 24 in this chapter

31. Write detailed notes on "Information Search Tools"/Index Services with examples.

Information Search tool: An information Search Tool gives the visitors a chance to find
something on a website by searching, much like the search engines such as Google. A
search tool will allow visitors to find the information quickly and without navigating
through hundreds of irrelevant results.

Generally, a web page contains many pages and lot of information. Though it has
better navigation options, many users want to locate a specific topic right away and
don’t want to follow links. Therefore, it is always a good idea to have a search facility in
every web site.

Information Search Tool is preferable in the following cases.


 Sites with valuable data in many pages
 Sites which get many visitors arriving from search engines
 Growing sites that are adding new and valuable information each day/week
 Sites that create unique pages to each user
Different Information Search Tools: Following are the parts of Information Search
Tools needed to allow users to search for information on a website.

1) Search Engine: It is a program that accepts the request from the form or URL,
searches the index, and returns the results page to the server. Search engine

B- Com III - Web Programming


Apoorva Publishers 163
searches for the keywords we enter ant returns list of URLs related to the
keywords. Search engine has the following components:
 Searcher: The part that searches a database for information to match the query.
 Evaluator: The function that assigns relevancy score to the information retrieved.
 Gatherer: The component that traverses the web collecting information. It uses
different search algorithms like depth/breadth first search.
 Indexer: The function that categorizes that data obtained.
2) Search Index File: Created by the Search Indexer program, this file stores the data
from the site in a special index or database, designed for very quick access.
Depending on the indexing algorithm and size of the site, this file can become very
large.
3) Search Forms: HTML interface to the site search tool, provided for visitors to enter
their search terms and specify their preferences for the search. Some tools provide
pre-built forms.
4) Search Results Listing: HTML page listing the pages which contain text matching
the search terms. These are sorted in some kind of relevance order, usually based
on the number of times the search terms appear, and whether they are in the title
or header. Most results listings include the title of the page and a summary.

32. Write an ASP script to display Date and Time.

To display Date and time in an ASP page, we use two VBScript functions date and time.
As the default language in ASP is VBScript, they will work without any other inclusions.
The program is shown below. It displays the current date and time.

<%
response.write ("Date = " & Date)
response.write ("<br>Time = " & Time)
%>

Output (Sample):
Date = 11/5/2010
Time = 5:58:46 PM

B- Com III – Web Programming


164 Apoorva Publishers

5 XML
1. What is XML? What are the features of XML?
2. What is XML? What are the Uses/Advantages/Benefits of XML?
3. What are the Origin and Goals of XML?
4. What is XML? Write the structure of XML with an example.
5. What are Elements and Attributes in XML?
6. What are the main Components (building blocks) of XML document?
7. Explain the Rules of XML Syntax. (Or) What are the rules for Elements and
Attributes in XML.
8. What is XML and How to Customize XML documents?
9. Write short notes on XSL (Extensible Style Language).
10. Explain in detail about XML Style sheets.
11. What is DTD? Explain with an example.
12. What are the Rules (Syntax) for Declaring Elements and Attributes in a
DTD? (Or) Explain Declaring Elements and Attributes in a DTD.
13. What is DTD? Explain with an example i) Internal DTD ii) External DTD
14. What is Hyperlink? How we can accomplish this using XML? Explain with
the help of an example. (Or) Discuss about the use of Hyperlinks in XML
with example.
15. Explain XLink and XPoiner with Examples.
16. Explain Types of Links in XML. (Or) Explain Simple, Extended Links.
17. Explain Link (Linking) Elements.
18. Explain Link Behavior in XML Links.
19. Explain Link Timing in XML Links.
20. Discuss about Attribute Remapping with an example.
21. Define XML Parser and explain how to use XML with HTML.
22. Write a brief note on XML Document Object Model with an example.
23. Explain about XML Query language.
24. What are the differences between XML and HTML?
25. What are the differences between CSS and XSL?
26. What are the differences between XML and XSL?
27. What is Namespace?

B- Com III - Web Programming


Apoorva Publishers 165
1. What is XML? What are the features of XML?

XML: XML stands for Extensible Markup Language. XML is a general-purpose markup
language. It is classified as an extensible language because it allows its users to define
their own elements. Its primary purpose is to facilitate the sharing of structured data
across different information systems, particularly via the Internet.

XML Features:
 XML is a subset of SGML
 XML is a set of rules for encoding documents in machine-readable form.
 XML is case sensitive
 XML supports DOM (Document Object Model)
 XML is designed to carry data, not to display data
 XML tags are not predefined. We must define our own tags
 XML is designed to be self-descriptive
 XML is a W3C Recommendation
 XML is the most common tool for data transmissions between all sorts of
applications.
 XML data is stored in plain text format
 XML is software and hardware independent.

2. What is XML? What are the Uses/Advantages/Benefits of XML?

XML: XML stands for Extensible Markup Language. XML is a general-purpose markup
language. It is classified as an extensible language because it allows its users to define
their own elements. Its primary purpose is to facilitate the sharing of structured data
across different information systems, particularly via the Internet.

Advantages (uses): Following are the different advantages or uses of XML


 XML Separates Data from HTML: With XML, data can be stored in separate XML
files. Thus, changes in the data will not require any changes to the HTML.
 XML Simplifies Data Sharing: XML data is stored in plain text format. This provides
a software- and hardware-independent way of storing data.
 XML Simplifies Data Transport: Exchanging data as XML greatly reduces this
complexity, since the data can be read by different incompatible applications.
 XML Simplifies Platform Changes: XML data is stored in text format. This makes it
easier to expand or upgrade to new operating systems, new applications, or new
browsers, without losing data.
 XML Makes the Data More Available: Different applications can access XML data,
not only in HTML pages, but also from XML data sources. With XML, the data can

B- Com III – Web Programming


166 Apoorva Publishers
be available to all kinds of "reading machines" (Handheld computers, voice
machines, news feeds, etc).
 XML is Used to Create New Internet Languages: A lot of new Internet languages
are created with XML. Following are some examples:
o XHTML
o WAP and WML as markup languages for handheld devices
o RSS languages for news feeds and many more

3. What are the Origin and Goals of XML?


Origin/History of XML:
 In the 1970’s, three staff members of IBM invented GML
 It became the Standard Generalized Markup Language (SGML) and was adopted by
the ISO in 1986.
 Hypertext Markup Language (First Version of HTML) was formally published on
June 1993.
 XML work began in mid-1996 when Sun Microsystems engineer Jon Bosak
developed a charter and recruited collaborators.
 XML was compiled by a working group of eleven members and was supported by
(approximately) 150-member Interest Group. The specification was to deliver a
semantic, extensible mark-up language with the power of SGML, yet the simplicity
of HTML.
 In February 1998 the World Wide Web Consortium (W3C) approved version 1.0 of
the XML specification.
 The XML 4th edition was released in August 2006.

XML Goals: The Goals of XML are defined by the XML W3C Working Group in the XML
Specifications as:
1. XML shall be straightforwardly usable over the Internet.
2. XML shall support a wide variety of applications.
3. XML shall be compatible with SGML.
4. It shall be easy to write programs which process XML documents.
5. The number of optional features in XML is to be kept to the absolute minimum,
ideally zero.
6. XML documents should be human-legible and reasonably clear.
7. The XML design should be prepared quickly.
8. The design of XML shall be formal and concise.
9. XML documents shall be easy to create.
10. Terseness in XML markup is of minimal importance.

4. What is XML? Write the structure of XML with an example.

B- Com III - Web Programming


Apoorva Publishers 167
XML: XML stands for Extensible Markup Language. XML is a general-purpose markup
language. It is classified as an extensible language because it allows its users to define
their own elements. Its primary purpose is to facilitate the sharing of structured data
across different information systems, particularly via the Internet.

Structure of XML: XML follows hierarchical tree like structure. This kind of
representation suits majority of data requirements. The structure of XML document is
shown below. XML documents may begin by declaring some information about
themselves, as in the following example (the first line).

<?xml version="1.0" ?>


<root>
<child>
<subchild> value </subchild>
….
</child>
<child>
value
</child>
:
</root>

Example: The following is a simple XML program. The root element in this program is
“address”.

<?xml version="1.0" ?>


<address>
<name>
<first> Ravi </first>
<last> Kumar </last>
</name>
<hno> 7/G </hno>
<street> Brindavan Colony </street>
<city> Karimanagr </city>
<pin> 505001 </pin>
</address>

Output: The output of the above program is shown below. When we click on “-“, the
elements collapse and the icon changes to “+”. Clicking this expands the child elements.
<?xml version="1.0" ?>
- <address>
- <name>
<first>Ravi</first>
<last>Kumar</last>

B- Com III – Web Programming


168 Apoorva Publishers
</name>
<hno>7/G</hno>
<street>Brindavan Colony</street>
<city>Karimanagr</city>
<pin>505001</pin>
</address>

5. What are Elements and Attributes in XML?

Element: Element is a logical component of a document which either begins with a


start-tag and ends with a matching end-tag, or consists only of an empty-element tag.
The characters between the start- and end-tags can be the content, or other elements,
which are called child elements. XML elements must follow these naming rules:
 Names can contain letters, numbers, and other characters
 Names cannot start with a number or punctuation character
 Names cannot contain spaces

Example (Non-empty tag) : <Greeting> Hello World </Greeting>


Example (Empty tag) : <line-break/>

Attribute: Attributes provide additional information about elements. They provide


information that is not a part of the data. Attribute is a construct consisting of a
name/value pair that exists within a start-tag or empty-element tag.

XML attributes must follow the following rules:


 If attributes are present, the values must be given in quotes (either single quotes
or double quotes).
 Valueless attributes are not allowed. The attribute-value pairs must be written in
full.
 Attributes cannot contain multiple values.

Example: In the following example, “alt” and “src” are attributes.


<img src="logo.jpg" alt="Apoorva" />

6. What are the main Components (building blocks) of XML document?

The Main Components (Building Blocks) of XML Documents: All XML documents are
made up by the following components. These are like different tokens in an XML
document.

B- Com III - Web Programming


Apoorva Publishers 169
 Elements: Elements are the main building blocks of both XML and HTML
documents. Examples of HTML elements are "body" and "table". XML has no
predefined elements as in HTML. Examples include "address" , “name” and "city".
Elements can contain text, other elements, or be empty.
Example: <name>Ravi</name>

 Attributes: Attributes provide extra information about elements. Attributes are


always placed inside the opening tag of an element. Attributes always come in
name/value pairs. The following "name" element has additional information about
age (i.e. an attribute).
Example: <name "age=25"> Ravi </name>

 Entities: Some characters have a special meaning in XML, like the less than sign (<)
that defines the start of an XML tag. To display such characters as they are, we use
entities. Entities are expanded when a document is parsed by an XML parser. The
following entities are predefined in XML:

Entity References Character


&lt; <
&gt; >
&amp; &
&quot; "
&apos; '

 PCDATA: PCDATA means parsed character data. PCDATA is text that will be parsed
by a parser. The text will be examined by the parser for entities and markup. Tags
inside the text will be treated as markup and entities will be expanded.

 CDATA: CDATA means character data. CDATA is text that will NOT be parsed by a
parser. Inside the CDATA tags, the text will NOT be treated as markup and entities
will not be expanded.
Example: <statement> <![CDATA[x>y?x:y]]> </statement>

 Comments: Comments are programmer friendly messages. The syntax of writing


comments is similar to as that of HTML comments. Following shows an example.
Example: <!-- My First XML Pagwe -->

7. Explain the Rules of XML Syntax. (Or) What are the rules for Elements and Attributes in
XML.

B- Com III – Web Programming


170 Apoorva Publishers
XML Syntax Rules: The syntax rules of XML are very simple and logical. The rules are
easy to learn, and easy to use. The rules are explained below.

 All XML Elements Must Have a Closing Tag: In HTML, some of the elements do not
require closing tag like the tag <p>, though it is not an empty tag like <hr>. But in
XML all non-empty tags must have a beginning and a closing tag.
Incorrect : <p> This is a paragraph
Correct : <p> This is a paragraph </p>

 XML Tags are Case Sensitive: XML tags are case sensitive. The tag <Letter> is
different from the tag <letter>. Opening and closing tags must be written with the
same case. Lower case element names are preferred in XML.
Incorrect : <address> This is a paragraph </Address>
Correct : <address> This is a paragraph </address>

 XML Elements Must be Properly Nested: In HTML, we might see improperly


nested elements. But, in XML, all elements must be properly nested within each
other.
Incorrect : <b> <i> Apoorva </b> </i>
Correct : <b> <i> Apoorva </i> </b>

 XML Documents Must Have a Root Element: XML documents must contain one
element that is the parent of all other elements. This element is called the root
element.
Incorrect : <name> Raj </name> <rno> 33 </rno>
Correct : <student> <name> Raj </name> <rno> 33 </rno> </student>

 XML Attribute Values Must be Quoted: XML elements can have attributes in
name/value pairs just like in HTML. In XML, the attribute values must always be
quoted; they may be omitted in HTML.
Incorrect : <font color=red> Apoorva </font>
Correct : <font color="red"> Apoorva </font>
 Empty tags must have strat and end tags or end with ‘/>’: All empty XML
elements must have strat and end tags or end with ‘/>’
Incorrect : <hr>
Correct : <hr/> or <hr></hr>

 Attribute minimization not allowed: XML does not support attribute minimization
as in the case of HTML (like checked). The attribute-value pairs must be written in
full.
Incorrect : <input type="radio" checked> Hi </input>
Correct : <input type="radio" checked="true"> Hi </input>
B- Com III - Web Programming
Apoorva Publishers 171
8. What is XML and How to Customize XML documents?

To customize XML documents, we use CSS (Cascade Style Sheet) formatting properties.
Using this, we can define how the user-defined tags should be displayed in the
browser. Here, we use external style sheets. The external style-sheet has to be
specified in the xml document using the following syntax.

<?xml-stylesheet type="text/css" href="somecssfile.css" ?>

Example: The following xml program when executed without “css”, only displays the
tree structure of elements. To format the elements, we have created “address.css” in
which the styles for the elements address, name, first, street, city, and pin are defined.
When we link the css file the output of the xml program will be different i.e. we will
have the formatted content displayed on the browser. The xml file (test.xml), css file
(address.css) and the output with and without style-sheets are shown below.

test.xml
<?xml version="1.0" ?>
<?xml-stylesheet type="text/css" href="address.css" ?>
<address>
<name>
<first> Ravi </first>
<last> Kumar </last>
</name>
<hno> 7/G </hno>
<street> Brindavan Colony </street>
<city> Karimanagr </city>
<pin> 505001 </pin>
</address>

address.css
address {display: block; border:"thin solid blue";
width:200; margin-bottom:20px}
name {color: blue; text-transform:uppercase;}
hno {display: block; font-style: italic;}
city, street {display: block; color: green;}
first {font-weight:bold;}
pin {color: red; font-size: 15pt; margin-left: 20pt;}

Output: Without CSS style sheet Output: With CSS style sheet

B- Com III – Web Programming


172 Apoorva Publishers

<?xml version="1.0" ?>


- <address>
- <name>
<first>Ravi</first>
<last>Kumar</last>
</name>
<hno>7/G</hno>
<street>Brindavan Colony</street>
<city>Karimanagr</city>
<pin>505001</pin>
</address>

9. Write short notes on XSL (Extensible Style Language).

XSL: XSL stands for EXtensible Stylesheet Language. The World Wide Web Consortium
(W3C) started to develop XSL because there was a need for an XML-based Stylesheet
Language. Though CSS can be used to format XML documents, W3C recommends XSL
to style XML documents. Therefore, XSL is the preferred Style Sheets for XML.

As the browser does not know how to display XML tags, XSL describes how the XML
document should be displayed. XSL is more than a Style Sheet Language and it consists
of three parts:
 XSLT: It is a language for transforming XML documents (Transformation)
 XPath: It is a language for navigating in XML documents
 XSL-FO: It is a language for formatting XML documents (Format Objects)

In simple terms, we can say that Extensible Stylesheet Language (XSL) is used to refer to
a family of languages used to transform and render XML documents.

Example: The following xml program uses xsl file (address.xsl) to style the xml
document (test.xml). Here, we are using the recommended stylesheet i.e. XSL
stylesheets to format our document. The output is also shown below.
test.xml
<?xml version="1.0" ?>
<?xml-stylesheet type="text/xsl" href="address.xsl"?>
<person>
<address>
<name> Srinivas </name> <city> Karimanagr </city>
</address>
<address>
<name> Ramu </name> <city> Hyderabad </city>
</address>
<address>
<name> Kiran </name> <city> Warangal </city>

B- Com III - Web Programming


Apoorva Publishers 173
</address>
</person>

address.xls
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>Persons Database</h2>
<table border="1">
<tr bgcolor="cyan">
<th>Name</th>
<th>City</th>
</tr>
<xsl:for-each select="person/address">
<tr>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="city"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

Output:

Persons Database
Name City
Srinivas Karimanagr
Ramu Hyderabad
Kiran Warangal

10. Explain in detail about XML Style sheets.

Stylesheets: Styles sheets are used to format HTML and XML documents. HTML can use
only CSS styles sheets, whereas XML documents can use both CSS style sheets and XSL
style sheets.

B- Com III – Web Programming


174 Apoorva Publishers
A) Using Cascade Style Sheet( CSS): Initially, Cascading Style sheets (CSS) were
used for formatting the data in the XML documents. It allows the Web Developers to
define a formatting for the elements in XML and the same can be applied to many
documents we like. The advantages are:
 It has a Precise control over presentation
 It is Resolution Independent
 It downloads Faster
 It is easy to maintain
Though it has a lot of advantages it also has following disadvantages.
 The order of elements for display cannot be changed
 An element cannot be processed more than once.
 Generated text cannot be added to the presentation

B) Using eXtensible Stylesheet Language (XSL): The difficulties that were


encountered with CSS were removed by making use of XSL. XSL is an application of XML
It allows us to create high performance XML based systems. The need for transforming
data from one format to the other results in splitting XSL into two groups:
1. XSLT: It describes how to transform XML i.e. XML document into other
formats.
2. XSL-FO: It describes formatting details of each element in the XML document.

1. XSLT: The XML Style sheet Language Transformation (XSLT) is a mechanism of


transforming one form of XML documents to the other form. It is a set of
templates based on Xpath expressions that tells how to fetch a particular node
from the XML documents. It is a part of XSL. XSLT is widely used in Websites
Content Management to convert XML into HTML pages. It uses Xpath to define
parts that match one or more templates. Xpath is a query language that allows us
to identify the nodes. It can select nodes in any direction. An XSLT processor is
used to perform transformations of XML document in to other formats based on
the given XSLT document.
2. XSL-FO: XSL-FO means Extensible Formatting Objects. There are two different ways
in which the XML document can be formatted. They are:
 Layout Based formatting: In a layout based formatting, the limitations of the
target may limit the content or appearance on the page
 Content Based formatting: In a Content Based Formatting, the target medium
is generated to accommodate the information being formatted. The XSL FO
allows us to make formatting and styling options to your document.

Note: Also, Refer to Examples in previous Two questions.

11. What is DTD? Explain with an example.

B- Com III - Web Programming


Apoorva Publishers 175
DTD: Document Type Definition (DTD) is a set of markup declarations that define a
document type for markup languages like SGML, XML and HTML. DTD defines the legal
building blocks of an XML document. It defines the document structure with a list of
legal elements and attributes. For example, a DTD for an XML document might address
the following issues:
 What should be the order of the tags?
 What tags can be nested?
 The minimum number of occurances of an entity
 Default values of attributes
 Set of enumerations values for attributes
 Whether the attributes are mandatory or optional

The Uses of DTD:


 With a DTD, each of the XML files can carry a description of its own format.
 With a DTD, independent groups of people can agree to use a standard DTD for
interchanging data.
 We can use a DTD to verify our own data or external data.
 A DTD validates an XML document

Valid XML document: An XML document is valid if it has an associated document type
definition and if the document complies with the constraints expressed in it.

DTD requires Declaring Elements and Declaring Attributes.


 Element declaration takes the following syntax:
<!ELEMENT element-name category>
Or
<!ELEMENT element-name (element-content)>
 Attribute declaration takes the following syntax:
<!ATTLIST element-name attribute-name attribute-type
default-value>
Example: Following is an internal DTD declaration within the XML document.

<?xml version="1.0" ?>


<!DOCTYPE address[
<!ELEMENT address (name,hno,city,pin)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT hno (#PCDATA)>
<!ELEMENT city (#PCDATA)>
<!ELEMENT pin (#PCDATA)>
]>
<address>

B- Com III – Web Programming


176 Apoorva Publishers
<name> Ravi Kumar </name>
<hno> 7/G, Brindavan Colony </hno>
<city> Karimanagr </city>
<pin> 505001 </pin>
</address>

The above DTD tells that:


 The root element is “address”.
 The order of the elements in <address> tag pair is name, hno, city, and pin.
 All the elements must occur in the same order
 All the elements can occur not more than once.
 All the elements take PCDATA type values.

12. What are the Rules (Syntax) for Declaring Elements and Attributes in a DTD? (Or)
Explain Declaring Elements and Attributes in a DTD.

DTD requires Declaring Elements and Declaring Attributes. The rules for declaring
elements and attributes are explained below.
Declaring Elements: In a DTD, XML elements are declared with an element
declaration with the following syntax:

<!ELEMENT element-name category>


Or
<!ELEMENT element-name (element-content)>

 Empty Elements: Empty elements are declared with the category keyword EMPTY:
<!ELEMENT element-name EMPTY>
Example: <!ELEMENT br EMPTY>

 PCDATA Elements: Elements with only parsed character data are declared with
#PCDATA inside parentheses:
<!ELEMENT element-name (#PCDATA)>
Example: <!ELEMENT city (#PCDATA)>

 Elements with any Contents: Elements declared with the category keyword ANY,
can contain any combination of parsable data:
<!ELEMENT element-name ANY>
Example: <!ELEMENT street ANY>

 Elements with Children (sequences): Elements with one or more children are
declared with the name of the children elements inside parentheses:
<!ELEMENT element-name (child1,child2,...)>

B- Com III - Web Programming


Apoorva Publishers 177
Example: <!ELEMENT address (name,hno,city,pin)>

Declaring Attributes: In a DTD, XML attributes are declared with an ATTLIST


declaration with the following syntax:
<!ATTLIST element-name attribute-name attribute-type
default-value>
Where,
 Element-name: This is the name of the element for which we want to specify
attribute constraints
 Attribute-name: This is the name of the attribute for which we want to specify
constraints
 Attribute-type: The attribute-type can be one of the following: CDATA,
Enumerated Values, ID, IDREF, IDREFS, NMTOKEN, NMTOKENS, ENTITY, ENTITIES
and so on.
 Default-Value: The default-value can be one of the following:
Value Explanation
value The default value of the attribute
#REQUIRED The attribute is required
#IMPLIED The attribute is not required
#FIXED value The attribute value is fixed

Example: <!ATTLIST address city CDATA "Karimnagar">

13. What is DTD? Explain with an example i) Internal DTD ii) External DTD

DTD: Document Type Definition (DTD) is a set of markup declarations that define a
document type for markup languages like SGML, XML and HTML. DTD defines the legal
building blocks of an XML document. It defines the document structure with a list of
legal elements and attributes. A DTD can be declared inline within the XML document,
or as an external reference.

Internal DTD Declaration: If the DTD is declared inside the XML file, it should be
wrapped in a DOCTYPE definition with the following rules and syntax.
 The document type definition must appear before the first element in the
document.
 The name following the word DOCTYPE in the DTD must match the name of root
element.
 Syntax: <!DOCTYPE root-element [element-declarations]>

Example: Following is an internal DTD declaration within the XML document.


B- Com III – Web Programming
178 Apoorva Publishers
<?xml version="1.0" ?>
<!DOCTYPE address[
<!ELEMENT address (name,hno,city,pin)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT hno (#PCDATA)>
<!ELEMENT city (#PCDATA)>
<!ELEMENT pin (#PCDATA)>
]>

<address>
<name> Ravi Kumar </name>
<hno> 7/G, Brindavan Colony </hno>
<city> Karimanagr </city>
<pin> 505001 </pin>
</address>

External DTD Declaration: In this, DTD is written in a separate file whose


extenson is “.dtd”. If the DTD is declared in an external file, it should be wrapped in a
DOCTYPE definition with the following syntax:
<!DOCTYPE root-element SYSTEM "filename">

Example: Following is external DTD declaration in a separate file (“address.dtd”). This


has to be linked using the DOCTYPE declaration in the xml document.

address.dtd:
<!ELEMENT address (name,hno,city,pin)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT hno (#PCDATA)>
<!ELEMENT city (#PCDATA)>
<!ELEMENT pin (#PCDATA)>

test.xml:
<?xml version="1.0"?>
<!DOCTYPE address SYSTEM "address.dtd">
<address>
<name> Ravi Kumar </name>
<hno> 7/G, Brindavan Colony </hno>
<city> Karimanagr </city>
<pin> 505001 </pin>
</address>

14. What is Hyperlink? How we can accomplish this using XML? Explain with the help of an
example. (Or) Discuss about the use of Hyperlinks in XML with example.

B- Com III - Web Programming


Apoorva Publishers 179
A link or hyperlink is some text or image which on clicking takes to other page, or other
website or another location in the same/other page. Hyperlinks facilitate non-linear
reading. HTML allows us to create hyperlinks using anchor tag. Anchor tag has one
mandatory attribute ‘href’ which specifies the target page or location.

Creating hyperlink in HTML is very easy. We use the anchor tag ‘<a>’ to create
hyperlinks. The general syntax is shown below.
<a href="url"> Text to act as hyperlink </a>
Example: <a href="www.apoorvacollege.com"> Visit Apoorva </a>

Hyperlinks in XML can be created in many ways. Three different methods are shown
below.
1. Using XLink
2. Using XPointer
3. Using XHTML namespace

1) Using XLink: We can create hyperlinks in an XML document using XLink. With
XLink we can define two types of links: simple links and extended links. Simple links are
links similar to HTML links and extended links are used for linking multiple resources
together.

XML does not use any predefined tags to create hyperlinks. We can use any tag to
create a hyperlink. However, we need to add a little bit of information to the tag to
change it from a normal XML node to an XML hyperlink node. Consider the following
example:
 The most important thing to notice in the following program is the usage of the
xmlns element. For XLink the namespace is http://www.w3.org/1999/xlink.
Without this declaration, we cannot use XLink in the document.
 It also requires two XLink attributes : xlink:type and xlink:href.
 The type element refers to the “type” of the hyperlink (Simple or Extended) and
“href” refers to the location to which this link should navigate to.
 To make the hyperlink work we have created “page.xsl” and linked it in the xml
document using <?xml-stylesheet ?> declaration.

test.xml:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="page.xsl" ?>
<page xmlns:xlink="http://www.w3.org/1999/xlink">
<mylink xlink:href="http://www.apoorvacollege.com"
xlink:type="simple"> Visit Apoorva </mylink>
</page>

B- Com III – Web Programming


180 Apoorva Publishers
page.xsl
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xlink="http://www.w3.org/1999/xlink">
<xsl:template match="mylink">
<br/><a href="{@xlink:href}"> <xsl:value-of select="." /> </a>
</xsl:template>
</xsl:stylesheet>

2) Using XPointer: XPointer also allows us to create hyperlinks. But, this allows us to
navigate to specific parts of an XML document. Sometimes it is useful to navigate to
specific areas of the same page or other pages . In HTML it is possible to do this using
the # character. In XML we can achieve the same by using XPointers. To navigate to a
specific part of a page we need to add a pound sign # and a XPointer expression after
the URL in the xlink:href. Consider the following example. The xml file (test.xml) creates
a link using XLink and XPointer to Smith’s details of the target XML document
“employees.xml”. We also require “xsl” file to make the hyperlink work. The xsl file
“page.xsl” given in the previous section should be used here also.

employees.xml

<?xml version="1.0" ?>


<employees>
<employee id="7369" >
<empno>7369</empno> <ename>Smith</ename> <job>Manager</job>
</employee>
<employee id="7452" >
<empno>7452</empno> <ename> James </ename> <job>Clerk</job>
</employee>
</employees>

test.xml

<?xml version="1.0" ?>


<?xml-stylesheet type="text/xsl" href="page.xsl" ?>
<page xmlns:xlink="http://www.w3.org/1999/xlink">
<mylink xlink:type="simple" xlink:href="employees.xml#7369">
Know More about Smith
</mylink>
</page>

B- Com III - Web Programming


Apoorva Publishers 181
3) Using XHTML Namespace: We can also create hyperlinks using XHTML
namespace. This namespace can be made available in the document through the
namespace value “http://www.w3.org/1999/xhtml”. Now, to create the hyperlink, we
use the element <html:a> in which “href” attribute takes the url value i.e. the location
to which we want to navigate. Consider the following example. To make the hyperlink
work we require a css file (page.css) which is shown below

test.xml
<?xml version="1.0" ?>
<?xml-stylesheet type="text/css" href="page.css" ?>
<page xmlns:html="http://www.w3.org/1999/xhtml">
<html:a href="http://www.apoorvacollege.com">
Visit Apoorva
</html:a>
</page>

page.css

page {display: block; width:100%; margin-left:10px; }

15. Explain XLink and XPoiner with Examples.

Note: Refer to Section 1 & 2 (Using XLink & Using XPointer) in the previous question.

16. Explain Types of Links in XML. (Or) Explain Simple, Extended Links.

Simple Links: Simple links are very much like HTML anchor element <A>, but with
more general reference capabilities. A simple link contains only one link and one target.
Following are the limitations on simple links:
 The source of the link is the link element itself
 There is only one target
 The title is carried by a single attribute

Simple Links View:

Source
Link Target

Example: The following code demonstrates creating a simple link.


<page xmlns:xlink="http://www.w3.org/1999/xlink">

B- Com III – Web Programming


182 Apoorva Publishers
<mylink xlink:href="http://www.apoorvacollege.com"
xlink:type="simple">
Visit Apoorva
</mylink>
</page>

Extended links: Extended links generally point to more than one target and from
more than one source. Both sources and targets are called as resources. In fact,
whether a resource is a source or a target can change depending on which link is being
followed and in which direction. Resources are divided into remote resources and local
resources.
 A local resource is actually contained inside the extended link element (xlink:type =
“resource”). That is, this type locates a local resource.
 A remote resource exists outside the extended link element, possibly in another
document. The extended link element contains locator child elements that point to
the remote resource (xlink:type = “locator”). That is, this type locates a remote
resource.
Extended Links offers the following advanced features:
 Multiple sources and targets using xlink:locator elements
 Multiple actuation possible using xlink:arc elements
 Multiple xlink:title elements

Extended Links View:

Locator Locator

Link

Locator Locator

Example: The following code demonstrates creating an extended link.

<WEBSITE xmlns:xlink="http://www.w3.org/1999/xlink"
xlink:type="extended">
<NAME xlink:type="resource"> Apoorva Downloads Page </NAME>
<HOMESITE xlink:type="locator"
xlink:href="http://www.site1.com/downloads/" />
<MIRROR xlink:type="locator"
xlink:href="http://www.site2.com/downloads /" />
<MIRROR xlink:type="locator"
xlink:href="http://www.site3.com/downloads /" />
</WEBSITE>

B- Com III - Web Programming


Apoorva Publishers 183
This WEBSITE element describes an extended link with four resources:
 Apoorva Downloads Page, a local resource
 The document at http://www.site1.com/downloads/, a remote resource
 The document at http://www.site2.com/downloads/, a remote resource
 The document at http://www.site3.com/downloads/, a remote resource

17. Explain Link (Linking) Elements.

Linking Elements: The XLink in XML is more flexible with tags because it creates not
only links but also describe elements. These descriptions may include link behavior,
type, link timing and etc. The different linking elements are identified by an xlink:type
attribute. The xlink:type attribute may take the following values.

 Simple: Simple links are very much like HTML anchor element <A>, but with more
general reference capabilities. A simple link contains only one link and one target.
 Extended: Extended links are used for linking multiple resources together. They
point to more than one target and from more than one source.
 Locator: A locator identifies a remote resource participating in a link. A locator is
possible only with extended links. There is a lcoator for each resource that
participates in an extended link.
 Resource: Resource identifies a local resource participating in a link. It is possible
only with extended links. A local resource is actually contained inside the extended
link element
 Arc: An arc is information about the origin, destination and behavior of a link
between two resources. The origin and destination resources are defined by labels.
By using one or more arcs, an extended link can achieve specific sets of
connections between multiple resources. It defines a traversal rule between any
combination of two locators and resources.

The common optional attributes with above linking elements are:


 Title: The title contains plain text that describes the resource, which is usually
displayed as a tooltip.
 Role: The role contains a URL pointing to a document that more fully describes the
resource.

Example: Following program demonstrates a linking element whose xlink:type attribute


is “simple”.

<mylink xmlns:xlink="http://www.w3.org/1999/xlink"
xlink:href="http://www.apoorvacollege.com"
xlink:type="simple"
xlink:title="More about the college"
B- Com III – Web Programming
184 Apoorva Publishers
xlink:role ="collegeprofile.html">
Visit Apoorva
</mylink>

18. Explain Link Behavior in XML Links.

Link Behavior: Linking elements can contain two optional attributes that suggest to
applications how the link behaves when activated. These are:
 xlink:show
 xlink:actuate

xlink:show: The xlink:show attribute talks about Link Effects. This attribute suggests
where the content should be displayed on the activation of the link. For example, by
opening a new window to hold the target content or by loading the target into the
current window. The xlink:show attribute has the following five possible values:
 Replace: If the value of xlink:show is replace, then when the link is activated by
clicking on it and the target of the link replaces the current document in the same
window. This is the default behavior of links in HTML documents.
 New: If the value of xlink:show is new, activating the link opens a new window in
which the targeted resource is displayed. This is similar to the behavior of HTML
links when the target attribute is set to _blank.
 Embed: If the value of xlink:show is embed, activating the link inserts the targeted
resource into the existing document. It implies that the application should render
the linked content and display it as part of that document itself. This is how the
IMG, APPLET, and OBJECT elements behave in HTML.
 Other: If the value of xlink:show is other, then the application is supposed to look
for other markup in the document that explains what to do. Generally, this would
be used when an XML application uses a non-XLink elements or attributes to
describe the link behavior.
 None: We can also set xlink:show to none to indicate that the document contains
no information to help the application decide what to do with the link. It is
completely up to the application reading the document to make its own choices.

Example: The following program uses “replace” value for xlink:show. It suggests that
the target of the lnik should be opened within the same window.

<link xlink:type="simple"
xlink:show="replace"
xlink:href="http://www.apoorvacollege.com">
Visit Apoorva
</link>

B- Com III - Web Programming


Apoorva Publishers 185
xlink:actuate: The xlink:actuate attribute talks about Link Timing. This attribute
suggests when the link should be activated; for instance, as soon as the document is
loaded or only after a specific user request. The xlink:actuate attribute has four
possible values:
 OnRequest: The value onRequest specifies that the link should be traversed only
when and if the user requests it. This is the behavior of a normal HTML link.
 OnLoad: If xlink:actuate attribute is set to onLoad, the link is traversed once the
document containing the link is loaded. For example, we might set the actuate
attribute to onLoad for an image to be embedded in the linking document. This
way the user doesn't have to click the link to follow it.
 Other: If the linking element's xlink:actuate attribute value is other, then the
application should look at other markup, not defined by XLink, to decide when to
traverse the link. For instance, a browser might define a PRELOAD element as
indicating that a document or image is not used on this page, but will likely soon be
used (background loading of image to be used).
 None: Setting xlink:actuate to none leaves it completely up to the application to
decide when or if to traverse the link.

Example: The following program uses “onrequest” value for xlink:actuate. It suggests
that the target of the lnik should be opened only when the user clicks on that link.

<link xlink:type="simple"
xlink:show="replace"
xlink:actuate="onrequest"
xlink:href="http://www.apoorvacollege.com">
Visit Apoorva
</link>

19. Explain Link Timing in XML Links.

Link Timing: Link timing in XML links suggests when the link should be activated. That
is, it may be when the document that contains the link is loaded or when the user clicks
on that and so on. This suggestions can be according to the value of “xlink:actuate”
attribute.

Note: Also, Refer to Section 2 (xlink:actuate) in the previous question.

20. Discuss about Attribute Remapping with an example.

Sometimes, it may be desired to use existing elements in XML documents as linking


elements, but such elements might already have attributes whose names conflict with
those described in the document.
B- Com III – Web Programming
186 Apoorva Publishers
For example, in the following XML code, the element “person” has an attribute “title’.
But, this title is not the title of the link used; it only represents the title of the person.

<person title="Mahathma" href="http://www.mkgandhi.org"/>

The problem with this is, the xlink:title (a predefined element of xlink) might assume
this “title” as link title and displays this when mouse hovers over the link. To avoid this,
we use attribute remapping.

Attribute Remapping: We use attribute remapping to avoid collisions. Here, the


user-chosen attributes can be declared as equivalent to those described in this
specification using the xml-attributes attribute.

The xml:attributes attribute lets us remap the attributes used. Its value is a series of
pairs, all separated by spaces. The first item in each pair is the name of an attribute
that an XLink processor expects to find, such as “title” or “role”; the second is the name
of the attribute that we actually used.

In the following example, since “title” is already used as title of the person, we might
want to use the attribute “link-title” as the title for the link. Following example
demonstrates this.

<person title="Mahathma" href="http://www.mkgandhi.org"


link-title="Mahathman Gandhi Biography"
xml:attributes="title link-title" />

In this case, the xml:attributes attribute says that the title of the link is in the “link-title”
attribute; the browser might display “Mahathma Gandhi Biography” when the mouse
hovers over the link, instead of “Mahathma”.

21. Define XML Parser and explain how to use XML with HTML.

XML Parser: An XML parser converts an XML document into an XML DOM object, which
can then be manipulated using Scripts or other programming languages. A parser does
two things.
1. It reads data from XML files and
2. It makes the information from those files available to other applications and
programming languages.

Using XML with HTML: To use XML data in HTML we use XML Data Source Object
(DSO). It is a Microsoft ActiveX control available with Microsoft Internet Explorer. This
object is a kind of parser that allows us to extract content from an external XML file or
B- Com III - Web Programming
Apoorva Publishers 187
XML data embedded in the HTML file into a HTML page. Using this object, we can
directly make use of XML data in HTML and display as per our requirement. Following is
the syntax used to create XML Data Source Object.

<XML ID="xmldso-name" src="xml-file-name"></XML>

Example: The following html program (test.html) creates XML Data Source Object that
uses data from the XML file “address.xml”. It then prints the data in a table using pure
HTML tags. Note that DATASRC attribute refers to XML DSO name and DATAFLD refers
to the elements of XML file. The output is also shown.

address.xml
<?xml version="1.0" ?>
<person>
<address>
<name> Srinivas </name> <city> Karimanagr </city>
</address>
<address>
<name> Ramu </name> <city> Hyderabad </city>
</address>
<address>
<name> Kiran </name> <city> Warangal </city>
</address>
</person>

test.html
<XML ID="xmldso" src="address.xml"></XML>
<table border=1 DATASRC="#xmldso">
<tr>
<td> <span DATAFLD="name"></span> </td>
<td> <span DATAFLD="city"></span> </td>
</tr>
</table>
Output:

Srinivas Karimanagr
Ramu Hyderabad
Kiran Warangal

22. Write a brief note on XML Document Object Model with an example.

XML DOM: The XML Document Object Model defines a standard way for accessing and
manipulating XML documents. The XML DOM views an XML document as a tree-

B- Com III – Web Programming


188 Apoorva Publishers
structure. The XML DOM defines the objects and properties of all XML elements, and
the methods (interface) to access them.
All elements can be accessed through the DOM tree. Their content (text and
attributes) can be modified or deleted, and new elements can be created. The
elements, their text, and their attributes are all known as nodes.

The XML DOM is:


 A standard object model for XML
 A standard programming interface for XML
 Platform- and language-independent
 A W3C standard

According to the DOM, everything in an XML document is a node. The DOM says:
 The entire document is a document node
 Every XML element is an element node
 The text in the XML elements are text nodes
 Every attribute is an attribute node
 Comments are comment nodes

Illustration: DOM is shown graphically for a sample XML below.

<bookstore>
<book>
<title lang="en"> DBMS BOOK</title>
<author> Venu </author>
<price> 170 </price>
</book>
</bookstore>

In the XML above, the <title> element is the


first child of the <book> element, and the
<price> element is the last child of the
<book> element.
Furthermore, the <book> element is the
parent node of the <title>, <author>, and
<year> elements.
Example: The following program(test.html) uses “Microsoft.XMLDOM” object to work
with the individual nodes of XML file (“address.xml” which is shown below). The
program uses DOM which collects data of the two element-nodes “name” and “city”
and prints them.

B- Com III - Web Programming


Apoorva Publishers 189
test.html
<script language="VBScript">
Set XMLDoc = CreateObject("Microsoft.XMLDOM")
XMLDoc.async = False
XMLDoc.load("address.xml")
n = XMLDoc.getElementsByTagName("address").length
document.write "<table border=1>"
for i=0 to n-1
document.write "<tr>"
document.write "<td>" & _
XMLDoc.getElementsByTagName("name")(i).childNodes(0).text
document.write "</td><td>" & _
XMLDoc.getElementsByTagName("city")(i).childNodes(0).text
document.write "</td></tr>"
next
document.write "</table>"
</script>

Address.xml
<?xml version="1.0" ?>
<person>
<address>
<name> Srinivas </name> <city> Karimanagr </city>
</address>
<address> <name> Ramu </name> <city> Hyderabad </city>
</address>
<address>
<name> Kiran </name> <city> Warangal </city>
</address>
</person>

Output:
Srinivas Karimanagr
Ramu Hyderabad
Kiran Warangal

23. Explain about XML Query language.

XML query language: Query languages are used to fetch information from a database
or a data source. The XML query language is known as XQuery. XQuery is designed to
query XML data, not only XML files, but also a document that can appear as XML,
including databases. XQuery is to XML what SQL is to database tables.

Features of XQuery:

B- Com III – Web Programming


190 Apoorva Publishers
 XQuery is the language for querying XML data
 XQuery for XML is like SQL for databases
 XQuery is built on XPath expressions
 XQuery is supported by all major databases
 XQuery is a W3C Recommendation

XQuery can be used to:


 Extract information to use in a Web Service
 Generate summary reports
 Transform XML data to XHTML
 Search Web documents for relevant information

Example: XQuery uses path expressions to navigate through elements in an XML


document. The following path expression is used to select all the “name” elements in
the "address.xml" file:

address.xml
<?xml version="1.0" ?>
<person>
<address>
<name> Srinivas </name> <city> Karimanagr </city>
</address>
<address> <name> Ramu </name> <city> Hyderabad </city>
</address>
<address>
<name> Kiran </name> <city> Warangal </city>
</address>
</person>

XQuery: doc("address.xml")/person/address/name

Explanation: The working of the above XQuery is explained below:


 doc(“address.xml”) loads the “address.xml” file,
 “/person” selects the person element,
 “/address” selects all the address elements under the person element, and
 “/name” selects all the name elements under each address element.
Output: The XQuery above will extract the following as output:

<name> Srinivas </name>


<name> Ramu </name>
<name> Kiran </name>

24. What are the differences between XML and HTML?


B- Com III - Web Programming
Apoorva Publishers 191
HTML XML
HTML stands for Hypertext Markup XML stands for Extensible Markup
Language Language
Its primary purpose is to format web Its primary purpose is to facilitate the
pages. sharing of structured data across different
information systems
HTML has predefined tags. This has no predefined tags; User needs
to create his own tags.
If it cannot understand a tag or HTML If XML code is not written properly, it
code is not written properly, it simply raises error
ignores that and does not raise any error
Does not require CSS for its display It requires CSS or XSL or DOM for its
display.
HTML is not Case sensitive XML is case sensitive
Attribute values need not be quoted Attribute values must be quoted
HTML is an application of SGML XML is a subset of SGML
Some tags require no closing tags. Every tag must be closed. Even empty
tags end with “/>”
No need of root element XML documents must have a root
element
Supports only simple links Supports simple and extended links
Creating links is very easy Creating links is complex

25. What are the differences between CSS and XSL?

CSS XSL
CSS stands for Cascade Style Sheets. XSL stands for Extensible Stylesheet
Langauge
It is meant to be used with HTML and It is meant to be used with XML. It can
can also be used with XML display, navigate, transform data of an XML
document
The order of elements for display The order of elements for display can be
cannot be changed changed
All elements will be displayed. We can choose the required elements for display
Generated text cannot be added to the Generated text can be added to the
presentation presentation.
An element cannot be processed more An element can be processed more than
than once. once.
CSS is very simple It is complex when compared to CSS
It has no programming constructs It has programming constructs like “if”, “for”
and etc.
B- Com III – Web Programming
192 Apoorva Publishers

26. What are the differences between XML and XSL?

XML XSL
XML stands for Extensible Markup XSL stands for Extensible Stylesheet
Language Langauge
Its primary purpose is to facilitate the Its primary purpose is to display, navigate,
sharing of structured data across different transform data of an XML document
information systems
It has no programming constructs It has programming constructs like “if”,
“for” and etc.
XML is a sub set of SGML XSL is a tool used to style XML documents
XSL should be bound (kinked) to XML for XSL refers to the elements of XML to
its display control their display
XML not only uses XSL for its display; It XSL is meant to be used with XML
may also use CSS
It has no programming constructs It has programming constructs like “if”,
“for” and etc.

27. What is Namespace?

XML namespaces are used for providing uniquely named elements and attributes in an
XML document. They are defined in a W3C recommendation. An XML instance may
contain element or attribute names from more than one XML vocabulary.

B- Com III - Web Programming


Apoorva Publishers 193

UNIVERSITY
PRACTICAL QUESTION-BANK
(FULLY SOLVED)
HTML Programs 194

VBScript Programs 206

ASP Programs 212

XML Programs 215

VIVA & SHORT questions 217

Exam Papers 236

B- Com III – Web Programming


194 Apoorva Publishers

1. Create a web page using HTML tags.

<body>
<h2>Welcome to APOORVA </h2>
<pre>
<h3> College Profile </h3>
Apoorva Degree College started in the
year 2000 with a vision to produce Skilled graduates.
<h3> Skill Development </h3>
Having realized the importance of skills to the graduates,
It started implementing skill building programs like
Personality development programs, soft skills training to
all its students.
<h3> Placements </h3>
Since 2007 college stood top in placements in Karimnagar
district. Students of Apoorva placed in top MNCs like
Infosys, TCS, CTS, Wipro and so on. College also achieved
University 5th rank and 6th Ranks.
</pre>
</body>
</html>

2. Create Ordered and Unordered lists using HTML tags.

B- Com III - Web Programming


Apoorva Publishers 195
<html>
<body>
<h1>Ordered List </h1>
<OL>
<LI> APPLE </LI>
<LI> MANGO </LI>
<LI> BANANA </LI>
</OL>
<h1>Unordered List </h1>
<UL>
<LI> Apple </LI>
<LI> Mango </LI>
<LI> Banana </LI>
</UL>
</body>
</html>

3. Design a Table using HTML table tags.


<html> Marks Memo
<html>
<body>
Name Rno Marks
<h1> Marks Memo </H1>
<table bgcolor=yellow border=1 width=200> Ravi 33 500
<tr> Kiran 44 600
<th> Name </th> <th> Rno </th>
Raju 55 700
<th> Marks </th>
</tr>
<tr>
<td> Ravi </td> <td> 33 </td>
<td> 500 </td>
</tr>
<tr>
<td> Kiran </td> <td> 44 </td>
<td> 600 </td>
</tr>
<tr>
<td> Raju </td> <td> 55 </td>
<td> 700 </td>
</tr>
</table>
</body>
</html>

B- Com III – Web Programming


196 Apoorva Publishers

4. Design a Super Script and Sub Script using HTML tags.

<html> Output:
<body> H2O
2 2
H<sub> 2 </sub> O <br> X +Y
X <sup> 2 </sup> + Y <sup> 2 </sup>
</body>
</html>

5. Create Personal Profile Using HTML Tags.

<html>
<body>
<center> <h2>PERSONAL PROFILE</h2> </center>
<table border=0 >
<tr>
<td> Name : </td>
<td> Kiran </td>
</tr>
<tr>
<td> Date Of Birth: </td>
<td> 12/7/1989 </td>
</tr>
<tr>
<td valign=top> Address: </td>
<td> 7/G <br>
Brindavan Colony <br>
Karimnagar <br>
505001 </td>
</tr>

<tr>
<td> E-mail: </td>
<td> [email protected] </td>
</tr>

<tr>
<td> Cell No: </td>
<td> 9999912345 </td>
</tr>
</table>

B- Com III - Web Programming


Apoorva Publishers 197
<h4> Educational Qualifications </h4>
<table border=1>
<tr>
<th> Qualification</th> <th> Percentage </th> <th> School/College </th>
</tr>
<tr>
<td> SSc </td> <td> 63% </td> <td> Loyolo High School </td>
</tr>
<tr>
<td> Intermediate </td> <td> 68% </td> <td> Vignan Junior College </td>
</tr>
<tr>
<td> Degree </td> <td> 81% </td> <td> Apoorva Degree College </td>
</tr>
</table>
<h4> Achievements </h4>
<ul>
<li> Participated in NSS camp 4 times </li>
<li> Donated Blood 3 times </li>
<li> Won first prize in college cultural competettions </li>
<li> Received Certficate of Appreciation from Collector </li>
</ul>
<h4> Strengths </h4>
<ul>
<li> I am a quick learner </li>
<li> Flexible and Hardworking </li>
<li> I am self driven and a go-getter </li>
</ul>
<h4> Computer Skills </h4>
<ul>
<li> C, HTML, ASP, Windows, MS-Office </li>
</ul>
</body>
</html>

Output:
PERSONAL PROFILE
Name : Kiran
Date Of Birth: 12/7/1989
Address: 7/G
Brindavan Colony

B- Com III – Web Programming


198 Apoorva Publishers
Karimnagar
505001
E-mail: [email protected]
Cell No: 9999912345

Educational Qualifications

Qualification Percentage School/College


SSc 63% Loyolo High School
Intermediate 68% Vignan Junior College
Degree 81% Apoorva Degree College

Achievements

 Participated in NSS camp 4 times


 Donated Blood 3 times
 Won first prize in college cultural competettions
 Received Certficate of Appreciation from Collector

Strengths

 I am a quick learner
 Flexible and Hardworking
 I am self driven and a go-getter

Computer Skills

 C, HTML, ASP, Windows, MS-Office

6. Write a program to display a table with a Row that spans in three Columns

<html> Output:
<body>
<table border=1> Row spans in 3 columns
<tr> <td colspan=3> Row spans in 3 columns
</td> </tr> One Two Three
<tr> <td> One </td> <td> Two </td> <td> Three
</td> </tr>
</table>
</body>
</html>

B- Com III - Web Programming


Apoorva Publishers 199
7. Write a HTML program to show ROWS that are Normal, Thick and Very Thick borders.

<html> Output:
<body>
<h4>With a normal border:</h4>
<table border="1">
<tr>
<td>One</td>
<td>Two</td>
</tr>
<tr>
<td>Three</td>
<td>Four</td>
</tr>
</table>

<h4>With a thick border:</h4>


<table border="8">
<tr>
<td>One</td>
<td>Two</td>
</tr>
<tr>
<td>Three</td>
<td>Four</td>
</tr>
</table>

<h4>With a very thick border:</h4>


<table border="15">
<tr>
<td>One</td>
<td>Two</td>
</tr>
<tr>
<td>Three</td>
<td>Four</td>
</tr>
</table>

</body>
</html>
B- Com III – Web Programming
200 Apoorva Publishers

8. Design i) Numbers ii) Letters and iii) Lower case lists Using HTML tags
<html> Output:
<body>
<h4>Numbers List </h4> Numbers List
<OL>
<LI> Apple </LI> 1. Apple
<LI> Mango </LI> 2. Mango
<LI> Banana </LI> 3. Banana
</OL>
<h4>Letters List </h4> Letters List
<OL type="A">
<LI> Apple </LI> A. Apple
<LI> Mango </LI> B. Mango
<LI> Banana </LI> C. Banana
</OL>
<h4>Lower Case Letters List </h4> Lower Case Letters List
<OL type="a">
<LI> Apple </LI> a. Apple
<LI> Mango </LI> b. Mango
<LI> Banana </LI> c. Banana
</OL>
</body>
</html>

9. Design i) DISC bullets and ii) Circle Bullets and using HTML tags
<html> Output:
<body>
<h4>Disc Bullets </h4> Disc Bullets
<UL type="disc">
<LI> Apple </LI>  Apple
<LI> Mango </LI>  Mango
<LI> Banana </LI>  Banana
</UL>
<h4>Circle List </h4> Circle List
<UL type="circle">
<LI> Apple </LI> o Apple
<LI> Mango </LI> o Mango
<LI> Banana </LI> o Banana
</UL>
</body>
</html>

B- Com III - Web Programming


Apoorva Publishers 201
10. Design a Time table using HTML table tags

<html>
<html> Time Table
<body>
<h1> Time Table </H1> Time Subject Lecturer
<table border=1 > 9-10 am Maths Kiran
<tr> 10-11 am Computers Ravi
<th> Time </th> <th> Subject </th>
<th> Lecturer </th> 11-12 pm Physics Arun
</tr> 12-1 pm Lunch -
<tr>
1-3 pm Lab -
<td> 9-10 am </td> <td> Maths </td>
<td> Kiran </td>
</tr>
<tr>
<td> 10-11 am </td> <td> Computers </td>
<td> Ravi </td>
</tr>
<tr>
<td> 11-12 pm </td> <td> Physics </td>
<td> Arun </td>
</tr>
<tr>
<td> 12-1 pm </td> <td> Lunch </td>
<td> - </td>
</tr>
<tr>
<td> 1-3 pm </td> <td> Lab </td>
<td> - </td>
</tr>
</table>
</body>
</html>

11. Create a webpage using Marquee tag.

<html>
<body bgcolor=orange text=blue>
<marquee bgcolor=lavender> WELCOME
TO APOORVA </marquee>

B- Com III – Web Programming


202 Apoorva Publishers
</body>
</html>

12. Create a webpage using HTML <ILAYER> tag.


Note: This works in Netscape Navigator

<html>
<body>
<p>This is my first paragraph.</p>
<ilayer name="layer1">
<p> This is the information On the layer </p>
</ilayer>
<p>This is my second paragraph.</p>
</body>
</html>

13. Create a webpage and insert an image with width 500 and height 300 and write a
small paragraph on that image. Give title as Image

<html>
<head> <title> IMAGE </title> </head>
<body>
<img src='apoorva.gif' width=500 height=300
alt="image">
<DIV STYLE="position:absolute; top:250px;
left:20px;">
<font color=blue size=6> Apoorva College
started in the year 2000
<br> and soon it became one of the best
colleges in Telangana region </font>
</DIV>
</body>
</html>

14. Create a webpage using HTML <ILAYER> tag.

Username:

Password:

B- Com III - Web Programming


Apoorva Publishers 203
<html>
<body>
<form>
User Name :<input type=text> <BR>
Password: <input type=password>
</form>
</body>
</html>

15. Create a webpage as shown below, that sends email form. This form sends an email
to gmail.

Name:
yourname
Mail:
yourmail
Comment:
yourcomment

<script language="JavaScript">
function sendMail()
{ var link =
"mailto:[email protected]"
+ "&subject=Comments"
+ "&body=" + f1.t1.value ;
window.location.href = link;

}
</script>
<html>
<head> <title> MAIL FORM DEMO </title> </head>
<body>
<form name="f1" >
<h2> This Form Sends an e-mail to GMAIL <h2>
Name: <BR>
<input type=text value='yourname'> <BR>
Mail: <BR>
<input type=text value='yourmail'> <BR>
Comment: <BR>
<input type=text size=30 name='t1' value="your
comment"> <BR>
<input type=button value='Submit'
onclick="sendMail()">

B- Com III – Web Programming


204 Apoorva Publishers
<input type=reset value='Reset'>
</form>
</body>
</html>

16. Design a frameset using HTML tags.


Note: First create three files “a1.html”, “a2.html”, and “a3.html” with some content

<html>
<frameset cols="25%,50%,25%">
<frame src='a1.html'>
<frame src='a2.html'>
<frame src='a3.html'>
</frameset>
</html>

17. Create a webpage showing an ordered list of names of five subjects

<html> Output:
<body>
<OL> 1. Maths
<LI> Maths </LI> 2. Physics
<LI> Physics </LI> 3. Computers
<LI> Computers </LI> 4. English
<LI> English </LI> 5. Telugu
<LI> Telugu </LI>
</OL>
</body>
</html>

18. Create a webpage showing an Unordered list of names of five vegetables


<html>
<body> Output:
<UL>  Brinjal
<LI> Brinjal </LI>  Tomato
<LI> Tomato </LI>  Ladies Finger
<LI> Ladies Finger </LI>  Carrot
<LI> Carrot </LI>  Beans
<LI> Beans </LI>
</UL>
</body>
</html>

B- Com III - Web Programming


Apoorva Publishers 205
19. Write HTML code to develop a web page having two frames that divide the web page
into two equal rows.

a1.html
<body>
<h1>First Document</h1>
</body>

a2.html
<body>
<h1>Second Document</h1>
</body>

main.html
<html>
<frameset rows="50%,50%">
<frame src='a1.html'>
<frame src='a2.html'>
</frameset>
</html>

20. Write HTML code to develop a web page having two frames and fill each frame with
different background colors.

a1.html
<body bgcolor=yellow>
<h1>First Document</h1>
</body>

a2.html
<body bgcolor=moonblue>
<h1>Second Document</h1>
</body>

main.html

<html>
<frameset rows="50%, 50%">
<frame src='a1.html'>
<frame src='a2.html'>
</frameset>
</html>

B- Com III – Web Programming


206 Apoorva Publishers

21. Create a webpage using all attributes of frame and other tags.

a1.html
<body bgcolor=yellow>
<h1>First Document</h1>
</body>

a2.html
<body bgcolor=moonblue>
<h1>Second Document</h1>
</body>

main.html
<html>
<frameset rows="50%, 50%">
<frame src='a1.html' name="f1" frameborder=1 noresize scrolling="yes"
marginheight=10 marginwidth=10>
<frame src='a2.html'>
</frameset>
</html>

VBSCRIPT PROGRMAS
1. Using VBScript display a line of text

<script language="VBScript"> Output:


document.write ("WELCOME TO APOORVA") WELCOME TO APOORVA
</script>

2. Design formatted text with HTML tags using VBScript

<script language="VBScript"> Output:


document.write ("<h1> Hello </h1>")
document.write ("<b> Hello </b><BR>") Hello
document.write ("<B>Hello </B> <BR>") Hello
document.write ("<I> Hello </I> <BR>") Hello
document.write ("<U> Hello </U> <BR>") Hello
document.write ("<TT>Hello<TT> <BR>") Hello
document.write ("<strike>Hello</strike> <BR>") Hello
document.write ("<font face='arial'> Hello </font>") Hello
</script> Hello
B- Com III - Web Programming
Apoorva Publishers 207
3. Using VBScript display a line with function in the head section

<html> Output:
<head>
<script language="VBScript"> sum of 30,40 = 70

Function sum (X,y)


sum=x+y
End Function
</script>
</head>
<body>
<script language="VBScript">
document.write "sum of 30,40 =" & sum (30,40)
</script>
</body>
</html>

4. Using VBScript display a script in the BODY section

<html> Output:
<head>
<title> script programs </title> Script in the body section
</head>
<body>
<script language="VBScript">
document.write "Script in the body section"
</script>
</body>
</html>

5. Using VBScript create and display variables

<script language="VBScript"> Output:


dim x,y
x=30 x = 30
y=40 y = 40
document.write "x = " & x
document.write " <br>y = " & y
</script>

B- Com III – Web Programming


208 Apoorva Publishers

6. Create and Insert a variable value in a text using VBScript code

<script language="VBScript"> Output:


dim x
x=30 value of x is 30
document.write "value of x is " & x
</script>

7. Create a list using array in VBScript code

<script language="VBScript"> Output:


s= Array("Apple", "Banana", "Mango", "Cherry")
document.write "<UL>"  Apple
For i = 0 To 3  Banana
document.write "<LI>" & s(i) & "</LI>"  Mango
next  Cherry
document.write "</UL>"
</script>

8. Using VBScript code create sub procedure

<script language="VBScript"> Output:


sum 30,40 'calling a procedure with arguments
Sum= 70
Sub sum(x,y)
document.write "<BR> Sum= " & (x+y)
end sub
</script>

9. Using VBScript code create Function procedure

<script language="VBScript"> Output:


document.write "Factorial of 4=" & Fact (4)
Function Fact (X) Factorial of 4= 24
F=1
For I=1 to X
F=F*I
Next
Fact=F
End Function
</script>

B- Com III - Web Programming


Apoorva Publishers 209

10. Using conditional If..then..else statement write a VBScript program


<script language="VBScript"> Output:
x=inputbox("enter a number")
If x Mod 2 = 0 Then Note: Depends on the given
document.write "Even number" number
Else
document.write "Odd number"
End If
</script>

11. Use VBScript If..then..elseIf statement with an example

<script language="VBScript"> Output:


x=MsgBox("Are U OK?", vbYesNoCancel, "Message")
If x=vbYes Then Note: Depends on the button
MsgBox "Yes is selected"
clicked
ElseIf x=vbNo Then
MsgBox "No is selected"
Else
MsgBox "Cancel is selected"
End If
</script>

12. Give an example for select case statement in VBScript

<script language="VBScript"> Output:


i=MsgBox("Are U OK?",vbYesNoCancel,"Message")
Select Case i Note: Depends on the button
Case vbYes
clicked
MsgBox "Yes is selected"
Case vbNo
MsgBox "No is selected"
Case Else
MsgBox "Cancel is selected"
End Select
</script>

13. Using an anchor tag display random links in VBScript.

B- Com III – Web Programming


210 Apoorva Publishers
<script language="VBScript"> Output (sample):
links = array ("yahoo", "apoorvacollege",_
"gmail", "winningbrains","facebook") Today's Random Link
randomize
http://www.facebook.com
s="http://www." & links(int(rnd()*5)) & ".com"
document.write "Today's Random Link <br>"
document.write "<a href=" & s & ">" & s & "</a>"
</script>

14. Using For..next loop in VbScript, write a VBScript program.

<script language="VBScript"> Output:


For x = 1 To 5 Hello
Document.write "<br> Hello" Hello
Next Hello
</script> Hello
Hello

15. Write a VBScript program using For-each loop. Give example.

<script language="VBScript"> Output:


x = Array(10, 20, 30) 10
For Each k In x
20
document.write "<br>" & k
Next 30
</script>

16. Using do-while loop give an example in VbScript

<script language="VBScript"> Output:


x=0 Hello
Do While x <5 Hello
document.write "<BR> Hello" Hello
x=x+1 Hello
Loop Hello
</script>

17. Using Date and Time functions Display Date and time

<script language="VBScript"> Output (Sample):


document.write "Date :" & date Date :1/20/2011
document.write "<br>Time :" & time Time :7:42:36 PM
</script>

B- Com III - Web Programming


Apoorva Publishers 211
18. Write a VBScript program to display the days.

<script language="VBScript"> Output :


for i=1 to 7 Sunday
document.write weekdayname(i) & "<br>" Monday
next Tuesday
Wednesday
</script>
Thursday
Friday
Saturday

19. Write a VBScript program to display the months

<script language="VBScript"> Output :


for i=1 to 12 January February March April May
document.write monthname(i) & " " June July August September October
next November December
</script>

20. Write a VBScript program to display current month and day

<script language="VBScript"> Output (Sample) :


document.write "Current Month: " & _ Current Month: January
monthname(month(date)) Current Day: Thursday
document.write "<br> Current Day: " & _
weekdayname(weekday(date))
</script>

21. Write a VBScript program to format Date and Time

<script language="VBScript"> Output :


d=CDate("22-01-2011 14:45") 1/22/2011 2:45:00 PM
document.write FormatDateTime(d) & "<br>" Saturday, January 22, 2011
document.write FormatDateTime(d,vbLongDate) & "<br>" 1/22/2011
2:45:00 PM
document.write FormatDateTime(d,vbShortDate) & "<br>"
14:45
document.write FormatDateTime(d,vbLongTime) & "<br>"
document.write FormatDateTime(d,vbShortTime) & "<br>"
</script>

B- Com III – Web Programming


212 Apoorva Publishers

ASP PROGRAMS
1. Create a HTML form (response.html) for ASP.

Response.html
<html>
<form name="frm" action="http://localhost/myasp/test.asp">
Name: <input type="text" name="t1" > <BR>
<input type="submit" value="submit">
</form>
</html>

Test.asp
<%
response.write("Hello" & request.querystring("t1"))
%>

Output:

After clicking the “submit” button


Hello Ravi

2. Write Response.asp program using HTML tags.

response.asp
<% Output:
response.write ("<h1> Hello </h1>")
response.write ("<b> Hello </b><BR>") Hello
response.write ("<B>Hello </B> <BR>")
response.write ("<I> Hello </I> <BR>")
Hello
response.write ("<U> Hello </U> <BR>") Hello
response.write ("<TT>Hello<TT> <BR>") Hello
response.write ("<strike>Hello</strike> <BR>") Hello
response.write ("<font face='arial'> Hello </font>")
%> Hello
Hello
Hello
Note: To execute the above program type the following line in the browser:
http://localhost/myasp/response.asp

3. Write an ASP code using Name, Colour.HTML

Color.html:
<html>

B- Com III - Web Programming


Apoorva Publishers 213
<form name="f1" action="http://localhost/myasp/test.asp">
<table border=0>
<tr>
<td>Name : </td> <td> <input type=text name="t1"> </td>
</tr>
<tr>
<td valign=top> Color : </td>
<td> <input type=radio value="red" name="c1"> Red <br>
<input type=radio value="green" name="c1"> Green <br>
<input type=radio value="blue" name="c1"> Blue
</td>
</tr>
</table>
<input type="submit" value="submit">
</form>
</html>

Test.asp
<%
response.write "Name: " & request.querystring("t1")
response.write "<br> Color: " & request.querystring("c1")
%>

Output:

After clicking the “submit” button


Name: Ravi
Color: green

4. Write an ASP code using Name, Colour.ASP

Colour.asp
<%
response.write "Name: " & request.querystring("name")
response.write "<br> Color: " & request.querystring("color")
%>

B- Com III – Web Programming


214 Apoorva Publishers
Note: To execute the above program type the following line in the browser:
http://localhost/myasp/colour.asp?name=ravi&color=red

5. Write a program using ASP forms with radio buttons and its methods.

Color.asp
<%
c=request.querystring("r1")
if c <> "" then
response.write "<body bgcolor=" & c &
">"
else
response.write "<body>"
end if
%>
<form name="frm" action="http://localhost/myasp/color.asp">
<input type=radio name="r1" value="red" onclick="VBScript:submit" > Red <br>
<input type=radio name="r1" value="yellow" onclick="VBScript:submit"> Yellow <br>
<input type=radio name="r1" value="pink" onclick="VBScript:submit"> pink<br>
</form>
</body>

6. Write an ASP code to display Date, Time and Text

<% Output (Sample):


response.write ("Date = " & Date) Date = 11/5/2010
response.write ("<br>Time = " & Time) Time = 5:58:46 PM
response.write ("<br>Hello") Hello
%>

B- Com III - Web Programming


Apoorva Publishers 215

XML - PROGRAMS
1. Write a letter as Document type definition (DTD)

Letter.dtd
<!ELEMENT letter (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>

Letter.xml
<?xml version="1.0"?>
<!DOCTYPE letter SYSTEM "letter.dtd">
<letter>
<to>Ravi</to>
<from>Apoorva</from>
<heading>Reminder</heading>
<body>All the best to your exams</body>
</letter>

2. Write a formatted article in XML

Article.xml:
<?xml version="1.0" ?>
<?xml-stylesheet type="text/css" href="article.css" ?>
<article>
<title> Importance of softskills </title>
<author> Kiran </author>
<abstract> This article talks about the importance of the
soft skills in todays' environment
</abstract>
<description>
Softskills are considerably imporatant for today's
youth. They improve one's emotional quotient and one's
performance dramatically...
</description>
<summary>
This article has examined the imporatance
of the softskills ..
</summary>

B- Com III – Web Programming


216 Apoorva Publishers
<reference>
7 habits of the highly effective people - S.R.Covey
</reference>
<reference>
Law of Success - Nepolian Hill
</reference>
</article>

Article.css:
article {display: block; border:"thin solid blue"; width:500; margin-bottom:20px}
title {color: blue; text-transform:uppercase;font-size:20pt}
abstract, summary {display: block; font-style: italic;}
description {display: block; color: gray; font-weight:bold;}
reference, author {display: block; color: red; font-size: 10pt; margin-left: 20pt;}

Output:

B- Com III - Web Programming


Apoorva Publishers 217

SHORT QUESTIONS

HTML VIVA/SHORT QUESTIONS


1. What is HTML?
HTML stands for Hyper-Text Markup Language. It allows us to create web pages. It does not
include any control structure and can produce only static content. A HTML page consists of
various tags that make a web page. The features, advantages and disadvantages of HTML page
are listed below.

2. What are the Features of HTML?


 It is a formatting language for text and images.
 It allows us to read the content nonlinearly by using hyperlinks to a file.
 HTML is an application of SGML.
 HTML uses markup tags to describe web pages
 It is not case sensitive i.e. code can be written in small case or uppercase letters.
 All the HTML documents have “.html” or “.htm” extension.
 HTML documents can be edited using editors such as notepad or front page.

3. What is a Tag?
HTML uses markup tags to describe web pages. HTML markup tags are usually called HTML tags.
HTML tags are keywords surrounded by angle brackets as in <tag-name> HTML tags normally
come in pairs like <tag-name> and </tag-name>.

4. What is the structure of a HTML page?


<! DOCTYPE …> version information
<HTML>
<HEAD>
...information about document, scripts, styles….
</HEAD>
<BODY>
...visible content of document….
</BODY>
</HTML>

5. What are Attributes?


Attributes provide additional information about an element (tag). All the tags can have
attributes. These attributes are always specified in the start tag. For example <img> tag has an
attribute named “src”.

B- Com III – Web Programming


218 Apoorva Publishers
6. What are the attributes of <BODY> tag?
Note: Refer to Q.No: 5 , Page No: 10

7. What is <HEAD> tag?


All the information contained in the document's head is loaded first, before any other thing in
the document, as it's defined before the body segment. It includes tags like title, script, style,
meta, base, basetag, index and so on.

8. What tags can be included in <HEAD> tag?


Note: Refer to Q.No: 6 , Page No: 11

9. What are Text (Character) formatting tags in HTML?

Tag Description
<b> Defines bold text
<i> Defines italic text
<u> Defines underlined text
<big> Defines big text
<small> Defines small text
<sub> Defines subscripted text
<sup> Defines superscripted text
<tt> Defines teletype text
<strike> Strikes off the text
<blink> Makes the text blinking
<font> Allows us to set font-face, color and size
<center> Aligns the text in center

10. List Paragraph Formatting tags.

Tag Description
<div> It defines a division in the document
<p > It defines a paragraph
<pre> Preformatted text, it writes text exactly as it is, including
spaces.
<br> forces the browser to start a new line
<blockquote> Blockquote produces text that is indented in from both
the left and right margins.
<address> This tag is used to enclose information such as "address,
signature and authorship"
<center> Center aligns the text/paragraph
<xmp> Similar to reformatting tag; it also ignores the html code
with in this tag.
<h1>, Generates headings in different sizes
<h2>,..<h6>

B- Com III - Web Programming


Apoorva Publishers 219
11. What are Logical Tags in HTML?

Tag Description
<strong> Defines strong text
<em> Defines emphasized text
<ins> Defines inserted text
<del> Defines deleted text
<code> Defines computer code text
<kbd> Defines keyboard text
<samp> Defines sample computer code
<var> Defines a variable
<abbr> Defines an abbreviation
<acronym> Defines an acronym
<address> Defines an address element. This tag is used to enclose information
such as "address, signature and authorship"
<bdo> Defines the text direction
<blockquote> Defines a long quotation. Blockquote produces text that is indented
from both the left and right margins.
<q> Defines a short quotation
<cite> Defines a citation
<dfn> Defines a definition term

12. What are Heading tags.


Headings are most common type of inclusion in any writing. It can be used to divide the page
into sections. In HTML there are six types of heading tags. <H1> to <H6>. When we use headings,
they automatically appear in new lines.

13. How do you write Comments in HTML documents?


The comment tag is an empty tag in which the comment is placed. The beginning of the tag is
"<!--" and the end of the tag is "-->". Any tags placed within the comment are ignored by the
browsers. Syntax: <!—a comment here -->

14. What is <FONT> tag?


The font tag is used to control the formatting of the text on the web page. It has attributes like
color, size and face.
Example: <font color=red face=”arial” size=6> Hi </font>

15. How do you achieve Text Scrollong?


The <MARQUEE> tag is used to create a scrolling text or image. A marquee can be made to scroll
from left to right or right to left.
Example: <marquee> Welcome </marquee>

16. What is <IMG> tag?

B- Com III – Web Programming


220 Apoorva Publishers
We use the Image tag to place images in web pages. The Image tag has no closing tag. But, it has
one required attribute (src), along with few other attributes like src, alt, width, height, align,
vspace, hspace, border and usemap.

17. What is <object> tag?


The object tag tells browser to include a multimedia application. The browser retrieves the file
specified in the DATA attribute. Other attributes are class id, code type, hspace and etc.
Example: <object data=“abc.wrl” height=“200” width=“200”> </object>

18. What is <embed> tag?


The embed-tag is similar to the object tag in that it allows us to include multimedia in an HTML
document. Example: <embed src=“pokiri.mid” height=“200” width=“200”>

19. What are the types of Lists in HTML?


The three types of lists are:
1. Ordered List (OL)
2. Unordered List (UL)
3. Definition List (DL)

20. What is Ordered List?


This gives numbering to the list items. The numbering could be Arabic numerals or roman
numeral or alphabets depending on the value of the ‘type’ attribute of ordered list. The tag used
is ‘<OL>’.

21. What is Unordered List?


This gives bullets to the list items. The bullets could be square type, circle type depending on the
value of the ‘type’ attribute of ordered list. The tag used is ‘<UL>’.

22. What is Definition List?


A kind of listing in which the definition term using <DT> and its description using <DD> can be
taken. The tag used for definition list is ‘<DL>’.

23. What is <TABLE> tag?


<TABLE> tag: To produce tables in html, we use <table> tag. The entire table element is
delimited by the <TABLE> and </TABLE> tags. It requires additional tags such as <th>, <tr> and
<td>.

24. What is <TR> tag?


<TR>: This tag is used to define a Table Row. Each table row is delimited by the <TR> and </TR>
tags. Table rows are nested within the table element described above.

25. What is <TD> tag?


<TD>: This tag is used to define Table Data i.e. value in each cell. Each cell (or table data) is
delimited by the <TD> and </TD> tags. The cells are nested within the table row element.

26. What is <TH> tag?


<TH>: This tag produces a row, which is normally used has header row. Each table header is

B- Com III - Web Programming


Apoorva Publishers 221
delimited by the <TH> and </TH> tags. Most browsers display the content of a table header cell
in boldface.

27. What are the attributes of <TABLE> tag?

Attribute Description
align Specifies the alignment of a table according to surrounding text.
Values can be: left, center, right
bgcolor Specifies the background color for a table
border Specifies the width of the borders around a table
cellpadding Specifies the space between the cell wall and the cell content
cellspacing Specifies the space between cells
width Specifies the width of a table

28. What is a Hyperlink?


A link or hyperlink is some highlighted text which on clicking takes to other page, or other
website or another location in the same page. Hyperlinks facilitate non-linear reading.

29. How do you create Hyperlinks in HTML?


HTML allows us to create hyperlinks using anchor (<A>) tag. Anchor tag has one mandatory
attribute ‘href’ which specifies the target page or location. The text that acts like hyperlink
should be delimited by <a> and </a>. An anchor can point to any resource on the Web: an HTML
page, an image, a sound file, a movie, etc. The syntax of creating an anchor (link): <a href="url">
Text to act as hyperlink </a>

30. What is FORM tag?


<FORM> tag: The <form> tag is used to create an HTML form for user input. A form can contain
input elements like text fields, checkboxes, radio-buttons, submit buttons and more. A form can
also contain select menus, textarea, and label elements. Forms are used to pass data to a server.

31. List Different Form elements?

Form Elements Description


Text A control that allows single line text
Password A control that allows the user to enter passwords
TextArea A control that allows multi- line text
Button An element that represents a button. The user presses or clicks to initiate
an action.
Submit Button Submit button sends values of form elements to a server.
Reset Button Reset button clears the information types in form elements.
Checkbox It is a control that provides the user with a toggle choice (checked or
unchecked).
Radio A "radio button" used in groups, where only one option at a time can be
selected.
File This displays a text box along with a “browse” that allows us to select
files from local computer. The selected file appears in the text box.

B- Com III – Web Programming


222 Apoorva Publishers
select This is an element used to create a list of items (similar to list boxes and
combo boxes)

32. What are HTML Frames?


In HTML, frames enable us to present multiple HTML documents within the same window. For
example, we can have a left frame for navigation and a right frame for the main content. To have
frames we use <frame> and <frameset> tags in an HTML file.

33. What is <FRAME> and <FRAMESET> tag?


Frames are achieved by creating a frameset page, and defining each frame from within that page.
This frameset page doesn't actually contain any content - just a reference to each frame. The
HTML <frame> tag is used to specify each frame within the frameset. All frame tags are nested
with a <frameset> tag.

34. What are Inline Frames?


Inline or “floating” frame is the one, which appear on a page like an ordinary element such as
tables or images. Using an inline frame, we can display a html page within some other html
page. The tag used for inline frames is <iframe>.

35. What is <HR> tag? (Or) How do you produce a horizontal ruler?
The <hr> tag creates a horizontal line in an HTML page. The hr element can be used to separate
content in an HTML page. It is an empty i.e. has no closing. Example: <hr width=”100%”>

36. What is <SPACER> tag?


The HTML <SPACER> tag is used to create a block of white space within an html document. This is
valid in Netscape browser.
Example: Touch Me <spacer type="horizontal" width="50"> Not

37. What is <BANNER> tag?


Banner tag directs the browser to render the banner graphics/text unmovable while the user scrolls
the remainder of the content. The banner text is delimited by the tags <banner> and </banner>. The
Banner tag is the first tag after the Body tag, before any text or other HTML coding.

38. What is <LAYER> tag?


The HTML <layer> tag is used to position and animate (through scripting) elements in a page. A
layer can be thought of as a separate document that resides on top of the main one, all existing
within one window. This tag has support in Netscape browsers.

39. Define WWW? (Or) What is Web?


WWW stands for World Wide Web. It is an Internet service developed to incorporate footnotes,
figures and cross-references into online hypertext documents. Hypertext documents are those in
which a user can jump to another location in the same document or any other document by
clicking on some highlighted text. WWW was created in 1989 at Geneva, Switzerland.

40. List common Image File Formats.


Note: Refer to Qno: 54, Page No: 50

B- Com III - Web Programming


Apoorva Publishers 223

VBScript VIVA/SHORT QUESTIONS


41. What is VBScript?
VBScript (Visual Basic Scripting Edition) is an Active Scripting language developed by Microsoft
that is derived from Visual Basic. VBScript is web programming language that can be embedded
into an HTML web page for client side scripting or used in ASP for server side scripting.

42. What are the Features of VBScript:


 It is developed by Microsoft
 It is a loosely typed programming language.
 VBScript programs are interpreted
 It is a light weight programming language
 It is derived from Visual Basic
 This is the default scripting language for ASP.
 It can be used for both client-side and server-side scripting.
 VBScript uses the Component Object Model
 VBScript is case-insensitive language

43. What are VBScript Data Types?


VBScript has only one data type called a Variant. A Variant is a special kind of data type that can
contain different kinds of information, depending on how it is used. Because Variant is the only
data type in VBScript, it is also the data type returned by all functions in VBScript. A Variant can
contain either numeric or string information. A Variant behaves as a number when we use it in a
numeric context and as a string when we use it in a string context.

44. What are variant sub data types?


Note: Refer to Q.No 2, Page No: 53 (Variant Sub types)

45. What is Client-side programming?


Client side programming is some code that runs in the web browser on the user’s computer. An
example of client-side programming is JavaScript. Client-side code is embedded within the web
page. VBScript, JavaScript, Jscript are the languages used for client-side programming.

46. What is Server-side programming?


Server-side programming is some code that runs on the web-server where the website is located.
The resulting code is sent to the browser (client) and displayed. Server-side programming can be
encrypted when users send form variables, ensuring more security. Some examples of server-
side programming languages are ASP, C#, VB.NET, and PHP.

47. What is Event Driven Programming?


 Events are various actions that take place in a program. Script can be invoked when an
associated event triggers. VBScript allows for event driven programming.
 A function or procedure will be executed only when the associated event triggers.

B- Com III – Web Programming


224 Apoorva Publishers
 Events can be triggered by performing specified action on different form elements or HTML
elements such as buttons, checkboxes, radio buttons, form, table and so on.

48. What are the Operators in VBScript?


Note: Refer to Q.No: 9, Page No: 61,62

49. Explain Control Structures in VBScript.


VBScript provides several types of control structure. They control the execution order and
number of times a block of statements gets executed etc. The types are given below.
 Branching (Conditional) Control Structures
 Iterative Control Structures (loops)
 Exit statements

50. What are Branching Control Structures in VBScript.


Branching Structures are used to choose among alternative statements of an action. VBScript
provides the following branching structures.
 If … Then … End If
 If … Then … Else … End If
 If … Then … ElseIf … End If
 Select Case … End Select

51. What are Iterative Control Structures (Loops) in VBScript?


Repetition structures allow a block of statements to get executed repetitively. The following are
the iterative structures provided with VBScript.
 Do While / Loop
 Do / Loop While
 Do Until/ Loop
 Do / Loop Until
 While ...Wend
 For ... Next
 For Each ... Next

52. What are Exit Statements in VBScript.


VBScript also provides exit statements to bring out the control from loops or sub-procedures or
function procedures.
 Exit Do
 Exit For
 Exit Sub
 Exit Function

53. Explain various Functions in VBScript.


There are many predefined functions in VBScript. They enhance the functionality of the scripts.
Following are the different categories of predefined (built-in) functions.
1. Math (Number) Functions
2. String (Text) Functions
3. Date and Time Functions
B- Com III - Web Programming
Apoorva Publishers 225
4. Conversion Functions
5. Formatting Functions
6. Logical Functions
7. Miscellaneous Functions
8. Array Functions
Note: Refer to Q.No: 16 to 23, from Page No: 70 to 75

54. What is an Array?


An array is a set of values of similar type. To work with arrays, VBScript provides several built in
functions: Array, IsArray, Join, Filter, Split, UBound, and LBound.

55. What is a sub procedure?


It is a reusable block of statements that does not return any value. A sub procedure can be
placed in a <sript> tag set. Each time the procedure is called, the statements between Sub and
End Sub are executed.

56. What is the syntax for a sub procedure?


sub procedurename(arg-list)
Statements
End Sub

57. What is a Function Procedure?


Functions are like sub procedures, except that they return a value to the calling procedure. The
default value returned by a Function procedure is a Variant.

58. What is the syntax for a Function procedure?


Function FunctionName (arg_list)
Statements
FunctionName=ReturnValue
End Function

59. What is MSGBOX?


MSGBOX displays a message in a dialog box, waits for the user to click a button, and returns a
value indicating which button the user clicked. The syntax of the function, its arguments are
shown below.
Syntax: MsgBox(prompt[, buttons][, title][, helpfile, context])

60. What is INPUTBOX?


INPUTBOX displays a prompt in a dialog box, waits for the user to input text or click a button, and
returns the contents of the text box.
Syntax: InputBox(prompt[, title][, default][, xpos][, ypos][, helpfile, context])

61. What are different Events?

B- Com III – Web Programming


226 Apoorva Publishers
Events Meaning
onclick When a mouseclick happens on an element
ondblclick When a mouse-doubleclick happens on an element
onblur When an element loses focus
onfocus When an element gets focus
onkeydown When a keyboard key is pressed
onkeyup When a key is released
onkeypress When a keyboard key is pressed or held down
onmousedown When a mouse button is held down
onmouseup When mouse button is released
onmousemove When mouse moves
onmouseout When muse cursor is moved out of the control
onmouseover When mouse moves over the control

62. What are Runtime errors?


VBScript run-time errors are errors that result when some script attempts to perform an action
that the system cannot execute. VBScript run-time errors occur while the script is being executed
or when variable expressions are being evaluated or when memory is dynamically allocated.
When runtime error occurs, a program will be terminated abruptly i.e. the program stops from
being executed

63. What is Error Handling?


Error handling: Error handling is a mechanism to handle runtime errors. Error handling enables
programmers to write error-free programs. Proper error handling ensures safe termination of a
program. We use ‘on error resume next’ statement to handle runtime errors in VBScript.
The Err Object provides information about the raised runtime error. Using Err object
allows the programmer to provide detailed error information.

64. What is Number Property?


Number property is a property of “Err” object. The Err Object provides information
about the raised runtime error.
The Number property is an integer that indicates the last error that occurred. To
determine which error has occurred, we check the value of Err.Number. For example,
for “division by zero” error the Err.number value will be ‘11’.

65. What is Data Validation


Data Validation is a process of verifying the correctness of values entered by the user. For
example, a name cannot contain digits and a pin-code cannot contain alphabets. If we don’t
perform data-validation, incorrect data is submitted to server and may cause serious problems to
the database.

66. What are Script engines and how they are helpful? Explain.
The script engine implements all the functions and procedures that can be used in script
programs. Without script engine, we cannot execute our script programs. Script engines are
provided by the operating system itself. The browser identifies the language of the script, and
then calls the appropriate scripting engine.
B- Com III - Web Programming
Apoorva Publishers 227

DHTML VIVA/SHORT QUESTIONS


67. What is DHTML?
DHTML stands for dynamic HTML. DHTML is not a programming or markup language like HTML.
It is a term that is used to describe the creation of dynamic and interactive pages. One of the
advantages of DHTML for web design and clients is that it can combine the use of HTML,
JavaScript/VBScript, XML and CSS (Cascading Style Sheets).

68. What are the advantages of DHTML?


 DHTML is more efficient for content management purposes.
 A rich set of graphical capabilities can be implemented
 Allows for event driven programming
 DHTML results in faster and fresher content, which is more visually appealing.
 Both content and layouts can be quickly manipulated
 DHTML content loads very fast
 Support for XML
 Supports DOM (Document Object Model)

69. Write the difference between HTML and DHTML.


Note: Refer to Q.No:2, Page No: 98

70. What are Cascading Style Sheets (CSS)?


CSS: CSS stands for Cascading Style Sheets. Cascading Style Sheet (CSS) is a style sheet language
used to describe the presentation semantics (the look and formatting) of a document written in a
markup language. The common application of CSS is to style web pages written in HTML and
XHTML, but the language can also be applied to any kind of XML document.

71. What are the types of style sheets?


1. Inline Style Sheets
2. External Style Sheets
3. Embedded Style Sheets
4. Imported Style sheets

72. What is Inline Style?


These are written inside the HTML document, style information on a single element, specified
using the "style" attribute as in <h1 style=“color:red”> hi </h1>

73. What is Embedded Style?


These are written as blocks of CSS information inside the HTML using <style> tag.
Example: <style> h1 { color:red;} </style>

74. What is External Style sheet?


These are separate “.CSS” files referenced from the document. We then link it in HTML file using
a tag like: <link href="mysheet.css" type="text/css" rel="stylesheet">
B- Com III – Web Programming
228 Apoorva Publishers
75. What is Imported Style sheet?
These are used to import “.css” files from other servers or other directories. It uses a statement
like @import url("http://www.htmlhelp.com/style.css") in <style> tag.

76. What are Style Classes?


 A general style that can be applied to any tag is known as a style class and is defined by
assigning a class name, preceded by a period (.), to its style properties. Style classes are also
known as class selectors.
 In the following example, a class named “.mystyle” is created. This can be used in any tag as
the value of “class” attribute with in that.
<style type="text/css">
.mystyle{font-family:arial; font-size:10pt; color:blue}
</style>
</head>
77. What are different CSS properties?
Note: Refer to 11 to 19, from Page No: 106 to 111

78. What is a filter?


Visual filters are prepackaged effects behavior that allow us to easily apply visual effects to their
content. Filters can be applied to HTML control elements through the CSS filter property. For
inline styles, the syntax for a filter property is: style="filter: filtername ( parameters )"

79. What are transitions?


Transitions are time-varying visual filters. Their use is to visually transition an object from one
state to the next. Two transition filters exist with Internet Explorer: Blend Transition and Reveal
Transition.

ASP VIVA/SHORT QUESTIONS


80. What is ASP?
Active Server Pages (ASP) is used to create dynamic and interactive Web pages. An ASP page is a
Hypertext Markup Language (HTML) page that contains script commands that are processed by
the Web server before sending it to the client's browser. An ASP file can contain text, HTML tags
and scripts. The scripting language can be VBScript, JavaScript and so on.

81. What are the Features of ASP?


 ASP stands for Active Server Pages
 ASP is a Microsoft Technology
 ASP is a program that runs inside IIS (IIS stands for Internet Information Services)
 ASP programs are meant for server side programming
 It is purely meant for web applications
 It supports DBMS and Active X controls
 It has so many built in objects and components.
 The asp files take the extension “.asp”.
 The default scripting language is VBScript.
B- Com III - Web Programming
Apoorva Publishers 229
82. What are the Advantages of ASP?
 Using ASP, we can dynamically edit, change, or add any content of a Web page
 It responds to user queries or data submitted from HTML forms
 It can access any data or databases and return the results to a browser
 We can customize a web page and make it more interactive and personal
 The advantages of using ASP instead of CGI and Perl, are those of simplicity and speed
 It provides security - since ASP code cannot be viewed from the browser
 ASP programming can minimize the network traffic.

83. What is the syntax of ASP program?


<%
ASP code
%>

84. What is the statement used in ASP to print text in the browser?
To send output to the browser, we use the following method.
response.write "some text"

85. What are the different types of tags used in ASP?


The tags used in ASP are:
Tag Meaning Example
<% %> ASP code <% Response.write("hi") %>
<%= %> To print a value <% x=30 %>
<%=x%> ' prints 30
<% ' %> Comment <% ' a comment here %>
<% @ %> Directives <%@ language= "VBScript" %>

86. What is ASP engine?


ASP Script engine is a server-side script engine. This is installed on the web server and is
responsible for processing ASP scripts. The ASP engine also invokes vbscript.dll to run VBScript
scripts or JavaScript engine to run JavaScript based scripts.

87. What are ASP objects?


Active Server Pages consist of the following seven important built in objects. They are readymade
objects, which provide functionality to the web pages. The objects are:
 Application Object
 ASPError Object
 ObjectContext Object
 Request Object
 Response Object
 Server Object
 Session Object

88. What is “Application” Object?

B- Com III – Web Programming


230 Apoorva Publishers
Application Object describes the methods, properties, and collections of the object that stores
information related to the entire Web application, including variables and objects that exist for
the lifetime of the application.

89. What is “ASPError” Object?


ASPError Object describes the properties of the object that stores information about an error
condition.

90. What is “ObjectContext” Object?


ObjectContext Object provides methods and events that are used only for transaction
processing.

91. What is “Request” Object?


Request Object describes the methods, properties, and collections of the object that stores
information related to the HTTP request. This includes forms, cookies, server variables, and
certificate data.

92. What is “Response” Object?


Response Object describes the methods, properties, and collections of the object that stores
information related to the server's response. This includes printing content, manipulating
headers, setting locales, and redirecting requests.

93. What is “Server” Object?


Server Object describes the methods and properties of the object that provides methods for
various server tasks. With these methods we can execute code, get error conditions, encode text
strings, create objects for use by the Web page, and map physical paths.

94. What is “Session” Object?


Session Object describes the methods, properties, and collections of the object that stores
information related to the user's session, including variables and objects that exist for the
lifetime of the session.

95. What is “FileSystemObject” Object?


The FileSystemObject is used to access the file system on a server. This object can manipulate
files, folders, and directory paths. It is also possible to retrieve file system information with this
object.

96. What is “TextStream” Object?


The TextStream object is used to access the contents of text files. To create an instance of the
TextStream object we can use the CreateTextFile or OpenTextFile methods of the
FileSystemObject object, or we can use the OpenAsTextStream method of the File object.

97. What is “File” Object?


File object is used to return information about a specified file. To work with the properties and
methods of the File object, we will have to create an instance of the File object through the
FileSystemObject object. First; create a FileSystemObject object and then instantiate the File

B- Com III - Web Programming


Apoorva Publishers 231
object through the GetFile method of the FileSystemObject object or through the Files property
of the Folder object.

98. What is “Folder” Object?


The Folder object is used to return information about a specified folder. To work with the
properties and methods of the Folder object, we will have to create an instance of the Folder
object through the FileSystemObject object. First; create a FileSystemObject object and then
instantiate the Folder object through the GetFolder method of the FileSystemObject object.

99. What is “Drive” Object?


The Drive object is used to return information about a local disk drive or a network share. The
Drive object can return information about a drive's type of file system, free space, serial number,
volume name, and more.

100.What is “Dictionary” Object?


The Dictionary object is used to store information in name/value pairs (referred to as key and
item). In a Dictionary object, each item is associated with a unique key. The key is used to
retrieve an individual item and is usually a integer or a string, but can be anything except an
array. The Dictionary object's properties and methods are described below:

101.What is “ADO”?
 ADO stands for ActiveX Data Objects
 ADO is a Microsoft Active-X component
 ADO is automatically installed with Microsoft IIS
 ADO is a programming interface to access data in a database

102.How do you access database from ASP page?


The common way to access a database from inside an ASP page is to:
 Create an ADO connection to a database
 Open the database connection
 Create an ADO recordset
 Open the recordset
 Extract the data needed from the recordset
 Close the recordset
 Close the connection

103.What is “Recordset” Object?


The ADO Recordset object is used to hold a set of records from a database table. A Recordset
object consist of records and fields. In ADO, this object is the one used most often to manipulate
data from a database. ADO Recordset object can be created using “CreateObject()” method of
Server object or the object can be returned by “execute” method of Connection object.

104.What are the different Comonenets of ASP?


ASP Components are the built-in components that enhance the functionality of the web pages.
The different components are:

B- Com III – Web Programming


232 Apoorva Publishers
 AdRotator Component
 Browser Capabilties Component
 Content Linking Component
 Content Rotator Component
 Page Counter Component.

105.What is “AdRotator” Component?


The ASP AdRotator component creates an AdRotator object that displays a different image
(banner) each time a user enters or refreshes a page.

106.What is “Browser capabilties” Component?


The ASP Browser Capabilities component creates a BrowserType object that determines the type,
capabilities and version number of a visitor's browser.

107.What is “Content Linking” Component?


The ASP Content Linking component is used to create a quick and easy navigation system. The
Content Linking component returns a Nextlink object that is used to hold a list of Web pages to
be navigated.

108.What is “Content Rotator” Component?


The ASP Content Rotator component creates a ContentRotator object that displays a different
content strings each time a visitor enters or refreshes a page. The strings can be links or images
or simple text (like a daily quote).

109.What is “Page Counter” Component?


The ASP PageCounter component is used to count number of hits made to a web site or a page.
Each time a user refreshes the page or a new user accesses the page, the pagecount value
increments.

XML VIVA/SHORT QUESTIONS


110.What is XML?
XML stands for Extensible Markup Language. XML is a general-purpose markup language. It is
classified as an extensible language because it allows its users to define their own elements. Its
primary purpose is to facilitate the sharing of structured data across different information
systems, particularly via the Internet.

111.What are the features of XML?


 XML is a subset of SGML
 XML is a set of rules for encoding documents in machine-readable form.
 XML is case sensitive
 XML supports DOM (Document Object Model)
 XML is designed to carry data, not to display data
 XML tags are not predefined. We must define our own tags
 XML is designed to be self-descriptive

B- Com III - Web Programming


Apoorva Publishers 233
 XML is a W3C Recommendation
 XML is the most common tool for data transmissions between all sorts of applications.
 XML data is stored in plain text format
 XML is software and hardware independent.

112.What is the structure of XML?


XML follows hierarchical tree like structure as shown below.

<?xml version="1.0" ?>


<root>
<child>
<subchild> value </subchild>
….
</child>
<child>
value
</child>
:
</root>

113.What are “elements” in XML?


Elements are the main building blocks of both XML and HTML documents. Examples of HTML
elements are "body" and "table". XML has no predefined elements as in HTML. Examples include
"address" , “name” and "city". Elements can contain text, other elements, or be empty.
Example: <name>Ravi</name>

114.What are “Attributes” in XML?


Attributes provide extra information about elements. Attributes are always placed inside the
opening tag of an element. Attributes always come in name/value pairs. The following "name"
element has additional information about age (i.e. an attribute).
Example: <name "age=25"> Ravi </name>

115.What are Entities in XML?


Some characters have a special meaning in XML, like the less than sign (<) that defines the start
of an XML tag. To display such characters as they are, we use entities. Entities are expanded
when a document is parsed by an XML parser.

116.Give examples for Entities in XML?


The following entities are predefined in XML:

Entity References Character


&lt; <
&gt; >
&amp; &
&quot; "
&apos; '

B- Com III – Web Programming


234 Apoorva Publishers
What is PCDATA?
PCDATA means parsed character data. PCDATA is text that will be parsed by a parser. The text
will be examined by the parser for entities and markup. Tags inside the text will be treated as
markup and entities will be expanded.

117.What is CDATA?
CDATA means character data. CDATA is text that will NOT be parsed by a parser. Inside the
CDATA tags, the text will NOT be treated as markup and entities will not be expanded. Example:
<statement> <![CDATA[x>y?x:y]]> </statement>

118.How do you write Comments in XML?


Comments are programmer friendly messages. The syntax of writing comments is similar to as
that of HTML comments. Following shows an example.
Example: <!-- My First XML Pagwe -->

119.What are XML syntax rules?


 All XML Elements Must Have a Closing Tag.
 XML Tags are Case Sensitive
 XML Elements Must be Properly Nested
 XML Documents Must Have a Root Element
 XML Attribute Values Must be Quoted
 Empty tags must have strat and end tags or end with ‘/>’
 Attribute minimization not allowed

120.What is XSL?
XSL stands for EXtensible Stylesheet Language. The World Wide Web Consortium (W3C) started
to develop XSL because there was a need for an XML-based Stylesheet Language. Though CSS can
be used to format XML documents, W3C recommends XSL to style XML documents.

121.What are the three sub-langauges of XSL?


 XSLT: It is a language for transforming XML documents (Transformation)
 XPath: It is a language for navigating in XML documents
 XSL-FO: It is a language for formatting XML documents (Format Objects)

122.What is DTD?
Document Type Definition (DTD) is a set of markup declarations that define a document type for
markup languages like SGML, XML and HTML. DTD defines the legal building blocks of an XML
document. It defines the document structure with a list of legal elements and attributes.

123.What is XLink?
We can create hyperlinks in an XML document using XLink. With XLink we can define two types
of links: simple links and extended links. Simple links are links similar to HTML links and extended
links are used for linking multiple resources together.

124.What is XPointer?

B- Com III - Web Programming


Apoorva Publishers 235
XPointer also allows us to create hyperlinks. But, this allows us to navigate to specific parts of an
XML document. Sometimes it is useful to navigate to specific areas of the same page or other
pages . In HTML it is possible to do this using the # character. In XML we can achieve the same by
using XPointers. To navigate to a specific part of a page we need to add a pound sign # and a
XPointer expression after the URL in the xlink:href.

125.What are the types of Links in XML?


 Simple Links: Simple links are very much like HTML anchor element <A>, but with more
general reference capabilities. A simple link contains only one link and one target.
 Extended links: Extended links generally point to more than one target and from more than
one source. Both sources and targets are called as resources

126.What is XML parser?


An XML parser converts an XML document into an XML DOM object, which can then be
manipulated using Scripts or other programming languages. A parser does two things.
1. It reads data from XML files and
2. It makes the information from those files available to other applications and programming
languages.

127.What is XML DOM?


The XML Document Object Model defines a standard way for accessing and manipulating XML
documents. The XML DOM views an XML document as a tree-structure. The XML DOM defines
the objects and properties of all XML elements, and the methods (interface) to access them.

128.What is XML Query Langauge? (Or) What is XQuery?


Query languages are used to fetch information from a database or a data source. The XML query
language is known as XQuery. XQuery is designed to query XML data, not only XML files, but also
a document that can appear as XML, including databases. XQuery is to XML what SQL is to
database tables.

ALL THE BEST

If you want to move the world, Move yourself first.

B- Com III – Web Programming


236 Apoorva Publishers
WEB PROGRAMMING (MODEL PAPER-1)
Time : 3 Hours] [Max. Marks : 70
Section A - (Marks : 5 x 4 = 20)
1. Answer any five of the following questions in not more than one page each.
a) Explain Graphics of HTML with the help of an example. (Q.No: 18, P:No: 19)
b) Explajn different Formatting tags in HTML. (Q.No: 7, P:No: 12)
c) What are the basic Data types in VB Script? (Q.No: 2, P:No: 53)
d) Explain Cascading style sheets. (Q.No: 3, P:No: 99)
e) What is an Event ? Explain Event handling in DHTML. (Q.No: 21, P:No: 111)
f) Explain about ASP Script Engines. (Q.No: 3, P:No: 134)
g) What is DTD ? Explain with an example. (Q.No: 11, P:No: 174)
h) What are the differences between XML & HTML? (Q.No: 24, P:No: 190)

SECTION - B (Marks 5 x 10 = 50)


Answer the following question in not exceeding four pages each :
2. (a) What is a Frame Set ? Explain how to create Horizontal and Vertical Frames.
(Q.No: 37, P:No: 35)
OR
(b) Discuss about Good Web Design Principles. (Q.No: 50, P:No: 48)
3. (a) What is Data Validation ? Write a program to show how data validation is
performed using VB Script. (Q.No: 40, P:No: 89)
OR
(b) Discuss about (i) User Interaction (ii) Handling Runtime Errors in VB Script.
(Q.No: 34, P:No: 84 and Q.No: 38, P:No: 88)
4. (a) Distinguish between Client Side Programming and Server Side Programming with
examples. (Q.No: 3, P:No: 54)
OR
(b) Explain about:(i) ON MOUSE MOVE event (ii) ON MOUSE OVER event (Hi) ON
MOUSE OUT event (Q.No: 24, 25, P:No: 114, 115)
5. (a) Explain about: (i) File System Object (ii) Text Stream Object (iii) Server Object
(iv) Dictionary Object in ASP. (Q.No: 13, 16, 17, 21 P:No: 143, 147,148,153)
OR
(b) Discuss about Content Linking and Ad-Rotator component in ASP.
(Q.No: 27,25 P:No: 159, 157)
6. (a) Explain in detail about XML Style sheets. (Q.No: 10, P:No: 173)
OR
(b) Discuss about the use of Hyperlinks in XML with example. (Q.No: 14, P:No: 178)

B- Com III - Web Programming


Apoorva Publishers 237
WEB PROGRAMMING (MODEL PAPER-2)
Time : 3 Hours] [Max. Marks : 70
Section A - (Marks : 5 x 4 = 20)
1. Answer any five of the following questions in not more than one page each.
a) Explain the following with minimum 2-3 attributes : (Q.No: 44, P:No: 44)
(i) <body> (ii) <font> (iii) <Basefont> (iv) <Marquee>
b) Differentiate Client and Serverside scripting. (Q.No: 3, P:No: 54)
c) Write the difference between HTML and DHTML. (Q.No: 2, P:No: 98)
d) How ASP pages really work? (Q.No: 4, P:No: 135)
e) Explain the features of XML. (Q.No: 1, P:No: 165)
f) Write a program to display a message box while clicking on the button using VB
script. (Q.No: 35, P:No: 86)
g) Discuss style classes with the help of an example. (Q.No: 10, P:No: 105)
h) Explain the Events Session - on Start and Session - on End. (Q.No: 15, P:No: 146)
SECTION - B (Marks 5 x 10 = 50)
Answer the following question in not exceeding four pages each :
2. (a) How to create graphical hyperlinks in HTML? Give example (Q.No: 31, P:No: 30)
OR
(b) Using table and its sub-tags create the following:- (Q.No: 24, P:No: 25)
Horses Race Time
Blueball Fortbell 525
Blue Prince Fortbell 6.5
3. (a) Write detailed notes on:- (i) Functions (ii) Procedures in VB Script with an
example. (Q.No: 29, P:No: 80)
OR
(b) Explain string manipulation mechanism with an example in VB.
(Q.No: 26, P:No: 78)
4. (a) Explain 4 Text properties and 4 Font properties in CSS.
(Q.No: 11, 12, P:No: 106, 107)
OR
(b) Discuss about Filters and Transitions existing in DHTML in detail.
(Q.No: 38, 39, P:No: 126, 129)
5. (a) Explain briefly about ASP objects. (Q.No: 8, P:No: 138)
OR
(b) Explain about: (i) Ad Rotator, (ii) Content Linking (iii) Page Counter components
In ASP. (Q.No: 25,27,29 P:No: 157, 159, 161)
6. (a) Explain the Document Object Model in XML. (Q.No: 22, P:No: 187)
OR
(b) Explain with an example about Internal and External DTDs. (Q.No: 13, P:No: 177)

B- Com III – Web Programming


238 Apoorva Publishers
WEB PROGRAMMING (MARCH-2011)
Time : 3 Hours] [Max. Marks : 70
Section A - (Marks : 5 x 4 = 20)

1. Answer any five of the following questions in not more than one page each.
(a) What is a HTML Frame? (Q.No: 37, P:No:35)
(b) What is Marquee tag? And explain its attributes. (Q.No: 15, P:No: 17)
(c) Define VB Script. (Q.No: 1, P:No: 53)
(d) What is Number Property? (Q.No: 64, P:No: 226)
(e) What is Dynamic HTML? (Q.No: 1, P:No: 98)
(f) What are the ASP Objects? (Q.No: 8, P:No: 138)
(g) What is XSL? (Q.No: 9, P:No: 172)
(h) What is Data Object Model? (Q.No: 22, P:No: 187)

SECTION - B (Marks 5 x 10 = 50)


Answer the following question in not exceeding five pages each:

2. (a) Explain the different HTML tags with their attributes: (Q.No: 5,6,7, P:No: 10)
OR
(b) What is a Frame? Explain about it. (Q.No: 37, P:No: 35)
3. (a) Define a variable. Explain its declaring procedure and rules. (Q.No: 6, P:No: 60)
OR
(b) Explain the various control structures in VB script. (Q.No: 10, P:No: 63)
4. (a) What is DHTML? Explain its features. (Q.No: 1, P:No: 98)
OR
:
(b) How do you create multimedia effects with filters and transitions?
(Q.No: 40, P:No: 130)
5. (a) Write about ASP Active Server Pages. (Q.No: 1, P:No: 133)
OR
(b) Explain about Information Search Tools/Index Services. (Q.No: 31, P:No: 162)
6. (a) What is XML? Explain its benefits. (Q.No: 2, P:No: 165)
OR
(b) Discuss the differences between XML and HTML. (Q.No: 24, P:No: 190)

B- Com III - Web Programming


Apoorva Publishers 239
WEB PROGRAMMING (MARCH -2012)
Time : 3 Hours] [Max. Marks : 70
Section A - (Marks : 5 x 4 = 20)
1. Answer any five of the following questions in not more than one page each.

(a) What is HTML? Explain its advantages. (Q.No: 1, P:No: 7)


(b) What is an image file extension? Give any six examples of image file extensions.
(Q.No: 54, P:No: 50)
(c) What is a variable and implicit declaration of a variable? (Q.No: 6 (section 1), P:No: 58)
(d) Explain: Join and Filter. (Q.No: 23 (Section 3 & 4), P:No: 75)
(e) What is Cascading Style Sheet (CSS)? (Q.No: 3, P:No: 99)
(f) What is ASP? Explain its importance. (Q.No: 1, P:No: 133)
(g) What is XSL? (Q.No: 9, P:No: 172)
(h) What is DTD? (Q.No: 11, P:No: 174)

SECTION B- (5 x 10 = 50 marks)

Answer the following questions in not more than b pages each.


2. (a) Explain the structure of a HTML page. (Q.No: 3, P:No: 8)
OR
(b) Describe different types of Lists in HTML. (Q.No: 21, P:No: 21)

3. (a) Explain different branching control structures in VB Script. (Q.No: 11, P:No: 63)
OR
(b) What are the VB Script dialog boxes (MSGBOX and INPUTBOX)? Discuss.
(Q.No: 33, P:No: 82)

4. (a) Explain the different types of selectors used in style Sheets with examples.
(Q.No: 9, P:No: 103)
OR
(b) What is a filter? Explain the different filters in DHTML. (Q.No: 38, P:No: 126)

5. (a) Discuss briefly ASP Objects. (Q.No: 8, P:No: 138)


OR
(b) Explain different components of ASP. (Q.No: 24, P:No: 156)

6. (a) What is .XML? Write the structure of XML with an example. (Q.No: 4, P:No: 166)
OR
(b) Explain XML Style Sheets. (Q.No: 10, P:No: 173)

B- Com III – Web Programming


240 Apoorva Publishers
WEB PROGRAMMING (MARCH -2013)
Time : 3 Hours] [Max. Marks : 70
Section A - (Marks : 5 x 4 = 20)
1. Answer any five of the following questions in not more than one page each.

a) Define HTML (Q.No: 1, P:No: 7)


b) What are the characteristics of web Images in HTML? (Q.No: 49, P:No: 47)
c) What is Event Driven Programming? (Q.No: 5, P:No: 58)
d) Define a Variable. How to declare a variable in VB Script?
(Q.No: 6, P:No: 58)
e) What is the difference between HTML and DHTML? (Q.No: 2, P:No: 98)
f) What are ASP tags? (Q.No: 7, P:No: 137)
g) Explain about ASP Script Engines (Q.No: 3, P:No: 134)
h) What are Link elements in XML? (Q.No: 17, P:No: 183)

SECTION B- (5 x 10 = 50 marks)
Answer the following questions in not more than b pages each.
2. a) Define Marquee tag. Explain its attributes. (Q.No: 15, P:No: 17)
OR
b) Explain Form elements in HTML. (Q.No: 33, P:No: 31)

3. a) Explain the Data Types in VB Script. (Q.No: 2, P:No: 53)


OR
b) Explain Array functions in VB Script with suitable examples. (Q.No: 23, P:No: 75)

4. a) Explain Cascading Style Sheets with suitable examples. (Q.No: 3, P:No: 99)
OR
b) Discuss Event Handling in DHTML. (Q.No: 21, P:No: 111)

5. a) Explain different components in ASP. (Q.No: 24, P:No: 156)


OR
b) Discuss about Data Access Technology in ASP. (Q.No: 22, P:No: 154)

6. a) Explain the main components of XML Document. (Q.No: 6, P:No: 168)


OR
b) What is the difference between Cascading Style Sheet (CSS) and
Extensible Style Sheet XSL? (Q.No: 25, P:No: 191)

B- Com III - Web Programming


Apoorva Publishers 241
WEB PROGRAMMING (MARCH -2013)
Time : 3 Hours] [Max. Marks : 70
Section A - (Marks : 5 x 4 = 20)
1. Answer any five of the following questions in not more than one page each.
a) Define HTML Explain briefly. (Q.No: 1, P:No: 7)
b) www (Q.No: 52, P:No: 49)
c) What are the advantages of VB Script? (Q.No: 1 (adv' of VB Script), P:No: 53)
d) Explain about image tag in HTML with suitable example. (Q.No: 16, P:No: 18)
e) Explain Active Server Pages. (Q.No: 1, P:No: 133)
f ) Define XML. (Q.No: 1, P:No: 165)
g) Define Name Space. (Q.No: 27, P:No: 192)
h) Define XSLT. (Q.No: XSLT part, P:No: 174)

Section B - (Marks:5 x 10 = 5Q)


Answer the following questions in not more than 5 pages each.
2. a) Explain different Formatting Tags in HTML with suitable example. (Q.No: 9, P:No: 13)
Or
b) Explain Frame Tag in HTML with suitable example. (Q.No: 37, P:No: 35)

3. a) Define VB Script. Explain structure of VB script. (Q.No: 4, P:No: 56)


Or
b) Explain Data Validation in VB Script. (Q.No: 40, P:No: 89)

4. a) How to create Multimedia Effects in DHTML? (Q.No: 40, P:No: 130)


Or
b) Explain different types of style sheets in CSS. (Q.No: 4, P:No: 100)

5. a) Explain Document Object Model. (Q.No: 22, P:No: 187)


Or
b) Explain different types of objects in ASP. (Q.No: 8, P:No: 138)

6. a) Define XML and differentiate between XML,HTML. (Q.No: 24, P:No: 191)
Or
b) Explain about Internal, External Document type definition. (Q.No: 13, P:No: 177)

B- Com III – Web Programming

You might also like