HTML-QnsAns Final
HTML-QnsAns Final
2023
Hours: 30
Paper : 21CAC- HTML, VBScript and
IA : 50
8 JavaScript
Exam: 50
Theory/Week:3
HoursCredits:3
Course Objective:
To train the student in understanding the Web environment.
To develop websites using HTML and CSS
To teach dynamic page creation using client side scripting JavaScript and
VBScript.
Course outcome:
After the Successful Completion of the course Students
will be ableCO1: To Identify the principles of web
coding and good design.
CO2: To demonstrate web page Design using HTML tags and features of CSS.
CO3: To apply examples of coding practice and dynamic web site design using
JavaScriptand VBScript.
MODULE – I 6 Hours
Introducing HTML and CSS: What is HTML is, What HTML Files Looks Like,
HTML Attributes, A Short History of HTML Standards,
.Learning the Basics of HTML : Structuring Your HTML, Organizing
information with Lists: Numbered Lists, Unordered Lists, Definition Lists, Nesting
Lists, The <img> tag, Image Backgrounds.
Working with Links: Creating Links, Linking Same Page and different pages using
Relative and Absolute Pathnames,
Building Tables: Creating Tables, Table Parts, Sizing tables, Borders and Cells,
Table and Cell color.
5) In HTML tables, gap between two cells of same table are known as.
A. Cell Spacing
B. Cell Padding
C. Cell Difference
D. None of the above
10) <DT> tag is designed to fit a single line of our web page but <DD> tag will accept a
A. line of text
B. full paragraph
C. word
D. request
11) Correct HTML to left align the content inside a table cell is
A. <tdleft>
B. <td raligh = "left">
C. <td align ="left">
D. <td leftalign>
12) The tag used to create a new list item and also include a hyperlink is
A. <LI>
B. <DL>
C. <DD>
D. <UL>
Understanding Level
13) How can you open a link in a new browser window?
A. < a href = "url" target ="new">
B. <a href = "url" target="_blank">
C. <a href = "url".new>
D. <a href = "url" target="open">
20) The web standard allows programmers on many different computer platforms to
dispersed format and display the information server. These programs are called
A. Web Browsers
B. HTML
C. Internet Explorer
D. None of these
25) Which attribute is used with <img> tag to display the text if image could not load in
browser?
A. Description
B. Name
C. alt
D. id
Long Questions
1) What is HTML? What are the Features of HTML?
HTML is an acronym which stands for Hyper Text Markup Language.
Hyper Text: Hyper Text simply means "Text within Text". A text has a link within it,
is a hypertext. Every time when you click on a word which brings you to a new
webpage, you have clicked on a hypertext.
Markup language: A markup language is a programming language that is used make
text more interactive and dynamic. It can turn a text into images, tables, links etc.
FEATURES:
It is a very easy and simple language. It can be easily understood and modified.
It is very easy to make effective presentation with HTML because it has a lot of
formattingtags.
It is a markup language so it provides a flexible way to design web pages along with
thetext.
It facilitates programmers to add link on the web pages (by html anchor tag), so it
enhancesthe interest of browsing of the user.
It is platform-independent because it can be displayed on any platform like
Windows,Linux and Macintosh etc.
It facilitates the programmer to add Graphics, Videos, and Sound to the web pages
whichmakes it more attractive and interactive.
1. a name and
2. a value
Examples:
Bgcolor RGB: it Specifies a background color for a document
Align left, right, center:- Deprecated − Specifies the alignment of the horizontal rule.
<HTML> Tag
It is the root of the html document which is used to specify that the document is
html. This tag tells the browser that this is an HTML document.
The <HTML> tag is the container for all other HTML elements (except for the
<!DOCTYPE> tag). Practically <HTML> is the first tag in an HTML page and
</HTML> is the last tag.
<HEAD> Tag
It contains the head of an HTML document, which holds informa
information
tion about the document
such as its title. Once we opened this tag then we must close it as </HEAD>.
Eg:
<html>
<head>
<title> welcome </title>
</head>
<body>
<h1>The example</h1>
<p> welcome to HTML </p>
</body>
</html>
<BODY> Tag
The HTML <BODY> tag is used for indicating the main
content section of the HTML document. This tag defines
the document's body. It contains all the contents of an
HTML document such as text, hyperlinks, images, tables,
lists, etc.
<BODY> tag is opened, it must be closed </BODY> before the closing of
</HTML> tag.
Example:
<html>
<body>
<img src="C:\Users\Public\Pictures\Sample Pictures\Tulips.jpg"
width="100" height="100" alt="Flower" border="5"
align="center" >
</body>
</ht
ml>
8) How do you create Hyperlink in HTML. Explain with example
The <A> tag defines a hyperlink, which is used to link from one page to another.
The most important attribute of the <A> element is the href attribute, which
indicates the link's destination.
By default, links will appear as follows in all browsers:
An unvisited link is underlined and blue
A visited link is underlined and purple
An active link is underlined and red
Ex: <a href="https://www.w3schools.com">Visit W3Schools.com!</a>
9) How to define table and what are the different attributes associate with it
with example explain.
An HTML table is defined with the <TABLE> tag. Each table row is defined
with the <TR>tag. A table header is defined with the <TH> tag. By default, table
headings are bold and centered. A table data/cell is defined with the <TD>tag.
<TH> Tag
The <TH> tag defines a header cell in an HTML table.
Header cells - contains header information (created with the <TH> element)
Standard cells - contains data (created with the <TD>
default.
<TD> Tag
The <TD> tag defines a standard cell in an HTML table.An HTML table has two
kinds of cells:
Header cells - contains header information (created with the <TH> element)
Standard cells - contains data (created with the <TD> element)The text in
<TH> elements is bold and centered by default. The text in <TD> elements
is regular and left-aligned by default.
10) Explain how to merge rows and columns in table HTML with example.
To merge table columns in HTML use the colspan attribute in <td> tag. With this, merge cells with each other
<!DOCTYPE html>
<html>
<head>
</head>
<body style="text-align:center">
<h1 style="color:green;">
welcome
</h1>
<table align="center">
<tr>
<th>Name</th>
<th>Age</th>
</tr>
<tr>
<td>Akku</td>
<td rowspan="2">44</td>
</tr>
<tr>
<td>fahad</td>
</tr>
</table>
</body>
</html>
11. Explain Absolute and Relative URL with example.
<h2>Relative URLs</h2>
<p><a href="html_images.asp">HTML Images</a></p>
<p><a href="/css/default.asp">CSS Tutorial</a></p>
A. text box.
B. radio button.
C. submit button.
D. All of these.
A. <select>
B. <text>
C. <textarea>
D. <dropdown>
3. Which HTML element is used to define multi-line input field?
A. <textarea>
B. <text>
C. <blockarea>
D. <textfields>
4. For defining a submit button which tag is used?
A. <button>
B. <submit button>
C. <submit>
D. <action submit>
5. When form data contains sensitive or personal information then which
method is more preferable?
A. Get method
B. Post method
C. Host method
D. Put method
6. In HTML form <input type=”text”> is used for?
A. One line text
B. Block of text
C. Paragraph
D. None
7. For creating a drop down list in HTML forms which element is suitable?
A. <list>
B. <dropdown>
C. <select>
D. All of the above
8. A ----------- tag defines a scale for the measurement of data within a
specified range.
A. Meter tag
B. Progress tag
C. Measure
D. Pre
9. <legend> is used to assign a caption to a set of form fields as defined by a
……………. element.
A) fieldset
B) caption
C) fieldgroup
D) assign
10. What is the default type of ‘type’ attribute of <input> element?
A. Text
B. Password
C. Numerals
D. Special Characters
11.Which attribute defines the file-select field?
A. file
B. checkbox
C. button
D. text
12.Which of the following is not used with password attribute?
A. name
B. size
C. maxlength
D. min
13.Which attribute is not used for the radio type?
A. name
B. value
C. checked
D. selected
14.Which attribute is used with <select> element?
A. multiple
B. selected
C. name
D. value
15. What is the purpose of HTML forms?
A. To display the content of an email.
B. To display animation effect.
C. To collect user input.
D. None of the above
The default value for the “position” attribute is _________.
A. fixed
B. absolute
C. inherit
D. relative
16.Choose the correct option
A. All of these
B. HTML form elements are defined inside form tag
C. HTML form elements are used for taking user input
D. HTML form elements can be of different types
17.Default method while submitting a form is
A. Set method
B. Post method
C. Get method
D. Put method
18.Action attribute in HTML forms specifies that
A. Which HTTP method is used
B. Where to submit form
C. Which action is going on
D. The auto completion
19.What is the default type of ‘type’ attribute of <input> element?
A. Special characters
B. Password
C. Numerals
D. Text
20.Which tag is used for grouping form controls?
A. <select>
B. <legend>
C. <label>
D. <fieldset>
21.How more than one option can be selected in drop down?
</body>
</html>
Radio Buttons are used when only one option is required to be selected. They are
created using
<input> tag as illustrated below.
Following is the list of important radiobox attributes:
· type: Indicates that you want to create a radiobox.
· name: Name of the control.
· value: Used to indicate the value that will be sent to the server if this
option isselected.
checked: Indicates that this option should be selected by default
<!DOCTYPE html>
<html lang="en">
<head>
<title>Progress tag</title>
</head>
<body>
<p>Normal Progress bar</p>
<progress></progress>
<p>Progress bar with max and value attributes</p>
<progress value="50" max="200"></progress>
<p>Progress bar with CSS</p>
<progress style="width:200px; height:40px;" ></progress>
</body>
</html>
Meter tag
A Meter tag is also known as a gauge and basically defines a scale for the
measurement of data within a specified range. The uses of a meter tag may
include the fuel left in the tank, the temperature of an object, etc. The meter tag is
written as follows.
Syntax:
<meter>....</meter>
Attributes: This tag accepts many attributes which are listed below.
· form: It defines one or more forms that the meter tag belongs to.
· max: It is used to specify the maximum value of a range.
· min: It is used to specify the minimum value of a range.
· high: It is used to specify the range considered to be a high value.
· low: It is used to specify the range value that is considered to below.
· optimum: It is used to specify the optimum value for the range.
· value: It is used to specify the required or actual value of the range.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Meter tag</title>
</head>
<body>
<p>Normal Meter</p>
<meter value="0.6"></meter>
<p>Meter tag with attributes</p>
<meter value="50" max="200" min="20"></meter>
<p>Meter tag with CSS</p>
<meter value="0.4" style="width:200px; height:40px;"></meter>
</body>
</html>
<FORM> Tag
The HTML <FORM> element defines a form that is used to collect user
input:
<h1>Hello world!</h1>
</body>
</html>
The CSS Grouping Selector
The grouping selector selects all the HTML elements with the same style definitions.
Look at the following CSS code (the h1, h2, and p elements have the same style definitions)
h1 {
text-align: center;
color: red;
}
h2 {
text-align: center;
color: red;
}
p{
text-align: center;
color: red;
}
It will be better to group the selectors, to minimize the code.
To group selectors, separate each selector with a comma.
h1, h2, p {
text-align: center;
color: red;
}
Example:
<html>
<body>
<form action="/cgi-bin/dropdown.cgi" method="post">
<select name="dropdown">
<option value="Maths" selected>Maths</option>
<option value="Physics">Physics</option>
<option value="Chemistry">Chemistry</option>
</select>
<input type="submit" value="Submit" />
</form>
</body>
</html>
Example:
<html>
<body style="background-color:yellow;">
<h2 style="background-color:red;">This is a heading</h2>
<p style="background-color:green;">This is a paragraph.</p>
</body>
</html>
</style>
</head>
<body>
I am Jahnavi. This is Internal Style sheet
<p> Cascading Style Sheets </p>
</body>
</html>
Example:
/* This is an external style sheet file. Save this file as
mystyle.css*/ hr
{
color: yellow;
}
h2
{
color: red;
text-align: left; font-size: 8pt;
That being said you’ll need to write custom CSS in order to change its appearance. The
default styling for the hr tag is pretty much similar across different browsers and consists of
CSS rules that style the border of the element.
hr {
border-style: inset;
border-width: 1px;
}
hr {
}
UNIT 3
Understanding Level
1. Javascriptis language.
A. Programming
B. Application
C. None ofThese
D. Scripting
5. JavaScript Code is
written inside filehavingextension .
A. .jvs
B. .javascript
C. .js
D. .jsc
9. ........................... A mostly used to take users choice on any option and displays
adialog
box with two buttons Ok and Cancel.
A. Alert dialogbox
B. Information dialogbox
C. Prompt dialogbox
D. Confirmation dialogbox
12. JavaScript statements embedded in an HTML page can respond to user events
such as mouse-clicks, form input, and page navigation.
A. Client-side
B. Server-side
C. Local
D. Native
Application Level
13. Which of the following can't be done with client-side JavaScript?
A. Validating a form
B. Sending a form's contents by email
C. Storing the form's contents to a database file on the server
D. None of the above
15. Which of the following attribute can hold the JavaScript version?
A. LANGUAGE
B. SCRIPT
C. VERSION
D. None of the above
18. What is the correct syntax for referring to an external script called "abc.js"?
A. <script href="abc.js">
B. <script name="abc.js">
C. <script src="abc.js">
D. None of the above
21. Which of the following event fires when the form element loses the focus:<button>,
<input>, <label>, <select>, <textarea>?
A. onfocus
B. onblur
C. onclick
D. ondblclick
22. method evaluates a string of JavaScript code in the context of the specified object.
A. Eval
B. ParseInt
C. ParseFloat
D. Efloat
25. The method of an Array object adds and/or removes elements from an array.
A. Reverse
B. Shift
C. Slice
D. Splice
Long Questions
• JavaScript gives HTML designers a programming tool - HTML authors are normally not
programmers, but JavaScript is a scripting language with a very simple syntax! Almost anyone
can put small "snippets" of code into their HTMLpages.
• JavaScript can react to events - A JavaScript can be set to execute when something
happens, like when a page has finished loading or when a user clicks on an HTMLelement
• JavaScript can read and write HTML elements - A JavaScript can read and change the
content of an HTMLelement
• JavaScript can be used to validate data - A JavaScript can be used to validate form data
before it is submitted to a server. This saves the server from extraprocessing
• JavaScript can be used to detect the visitor's browser - A JavaScript can be used to
detect the visitor's browser, and - depending on the browser - load another page specifically
designed for thatbrowser
• JavaScript can be used to create cookies - A JavaScript can be used to store and retrieve
information on the visitor'scomputer
2. What is variable? How to declare the variable in JavaScript? What are the
variable naming conventions?
JavaScript variables are containers for storing data values. Each variable is given a name so
that you can refer to it elsewhere in your code.
Declaring a variable in JavaScript:
<html>
<body>
<h2>JavaScript Variables</h2>
<p>In this example, x, y, and z are variables.</p>
<p id="demo"></p>
<script>
var x = 5;
var y = 6;
var z = x + y;
document.getElementById("demo").innerHTML =
"The value of z is: " + z;
</script>
</body>
</html>
OUTPUT:
JavaScript Variables
In this example, x, y, and z are variables.
The value of z is: 11
Text Data
Another term for one or more characters of text is a string.
We tell JavaScript that text is to be treated as text and not as code simply by enclosing it
inside quote marks ("). For example, "Hello World" and "A" are examples of strings that
JavaScript will recognize. You can also use the single quote marks (')
Boolean Data
The use of yes or no, positive or negative, and true or false is commonplace in the "real"
world.
The idea of true and false is also fundamental to digital computers; they don't
understand maybes, only true and false. In fact, the concept of "yes or no" is so useful it has
its own data type in JavaScript: the Boolean data type.
The Boolean type has two possible values: true for yes and false for no.
if(myNum == 7){
document.write("Lucky 7!");
}
</script>
if(myNum ==7){
document.write("Lucky 7!");
}else{
document.write("You're not very lucky today...");
}
</script>
If...else if...else Statement
Use the if....else if...else statement to select one of several blocks of code to be executed.
Syntax
if (condition1)
{
code to be executed if condition1 is true
}
else if (condition2)
{
code to be executed if condition2 is true
}
else
{
code to be executed if neither condition1 nor condition2 is true
}
Example
If the time is less than 10:00, you will get a "Good morning" greeting, if not, but the time
is less than 20:00, you will get a "Good day" greeting, otherwise you will get a
"Goodevening" greeting:
if (time<10)
{
x="Good morning";
}
else if(time<20)
{
x="Goodday";
}
else
{
x="Good evening";
}
The result of x will be:
Good day
The switch statement is used to perform different action based on different conditions.
The JavaScript Switch Statement
Use the switch statement to select one of many blocks of code to be executed.
Syntax
switch(n)
{
case 1:
execute code block 1
brea
k;
case
2:
execute code block 2
brea
k;
defa
ult:
code to be executed if n is different from case 1 and 2
}
This is how it works: First we have a single expression n (most often a variable), that is
evaluated once. The value of the expression is then compared with the values for each case
in the structure. If there is a match, the block of code associated with that case is executed.
Use break to prevent the code from running into the next case automatically.
Example
Display today's weekday-name. Note that Sunday=0, Monday=1, Tuesday=2,
etc: var day=new Date().getDay();
switch (day)
{
case 0:
x="Today
it'sSunday"; break;
case1:
x="Today it's
Monday"; break;
case2:
x="Today it's
Tuesday"; break;
case 3:
x="Today it'sWednesday";
break;
case4:
x="Today it's
Thursday"; break;
case5:
x="Today it's
Friday"; break;
case 6:
x="Today it's
Saturday"; break;
}
The result of x will be:
Today it's Tuesday
The default Keyword
Use the default keyword to specify what to do if there is no match:
Example:
<html>
<body>
<h2>JavaScript While Loop</h2>
<p id="demo"></p>
<script>
let text = "";
leti = 0;
while (i<5) {
text += "<br>The number is " + i;
i++;
}
document.getElementById("demo").innerHTML = text;
</script>
</body>
</html>
Output:
JavaScript While Loop
The number is 0
The number is 1
The number is 2
The number is 3
The number is 4
7. Explain how to declare and access array object in JavaScript with example.
Arrays are special memory locations because it can hold more than one
value at a time, and you can access these values individually.
Example:
varmyVar = 10; //Variable Declaration
varmyVarArray = new Array(); //Array Declaration
varweekArray = new
Array("Sunday","Monday","Tuesday"); if
(weekArray.contains('Sunday')) {
// write your code here
}
Array.sort
JavascriptArray.sort() method sort the elements in an Array either Alphabetic or Numeric,
also you can sort ascending or descending. The default sort order is alphabetic and
ascending.
Alphabetical Order
varweekArray = new
Array("Sunday","Monday","Tuesday"); weekArray.sort();
The array order will be...Monday, Sunday, Tuesday
weekArray.reverse();
The array order will be...Tuesday, Sunday, Monday
Numerical Order
varnumArray = [80,30,50,40];
numArray.sort()
The array order will be..30, 40, 50,
80 numArray.reverse();
The array order will be..80, 50, 40, 30
Array.splice()
The splice() method in Javascript add new elements to the Array and removing old elements
from Array.
var colors = ["Red", "Blue", "Green"];
colors.splice(2,0,"Yellow","Orange");
colors.splice(2,0,"Yellow","Orange") means that add new elements at the array index 2 and
removed 0 elements.
The array order will be ...Red, Blue, Yellow, Orange, Green
Array.slice()
The slice() method in Javascript retrieve the elements starting at the first argument, and ends at
second argument-1.
var colors = ["Red", "Blue", "Green", "Yellow","Orange"];
varselectedColors = colors.slice(1, 3);
The selectedColors are...Blue,Green.
colors.slice(1, 3) select 1 to 3-1 elements from colors.
Array.join()
The join() method in Javascript will be separated by a specified separator with given
argument. var colors = ["Red", "Blue", "Green"];
alert(colors.join('#'));
The result will be
Red#Blue#Greenalert(colors.join
(''));
The result will be RedBlueGreen
9. What is a function? How to define and call function in JavaScript with example.
Javascript functions are considered as first-class objects, because they can be manipulated
like any other object in the language. Javascript functions can have properties and methods,
also it can be passed as arguments
Each function in your JavaScript must be addressing it by a unique name for that particular
page. Always use meaningful function names, so that when you see it being used later in
your programming code. Function names are case sensitive, that is a function name "callMe"
is not same as "callme"
Function Declarations:
Syntax:
functionfunctionName(parameters (optional))
{
FunctionBody
}
The parameter is optional, you can write function without any
parameters. E.g.
Function without arguments
function greetings()
{
alert("Good morning");
}
Function with arguments
functionfindSum(a,b)
{
alert("Sum is : " + (a + b));
}
Calling a Function:
You can call Javascript functions by simply call the function name.
function greetings()
{
alert("Good Morning");
}
greetings(); //just give the function name only When you
run the above code, it will alert "Good Morning".
<script>
function greetings(name)
{
alert("Good morning " + name);
}
greetings("John");
</script>
When you run the above code , it will alert "Good morning
John". Function with two arguments
10. Explain Alert Box and Confirmation Box with syntax and example.
Alert Box
An alert box is often used if you want to make sure information comes through to the user.
When to Use Popups / Alerts
JavaScript alerts are ideal for the following situations:
If you want to be absolutely sure they see a message before doing anything onthe
website.
You would like to warn the user about something. For example "the followingpage
contains humor not suitable for those under the age of14."
An error has occurred and you want to inform the user of theproblem.
When asking users for confirmation of some action. For example, if they have just
agreed to sign over the deed to their house and you want to ask them again if they are
absolutely positive they want to go through with thisdecision!
When an alert box pops up, the user will have to click "OK" to proceed.
Syntax
alert("sometext");
Example
<html>
<head>
<script>
functionmyFunction()
{
alert("I am an alert box!");
</script>
</head>
<body>
<input type="button" onclick="myFunction()" value="Show alert box" />
</body>
</html>
Confirm Box
A confirm box is often used if you want the user to verify or accept something.
When a confirm box pops up, the user will have to click either "OK" or "Cancel" to proceed.
The JavaScript confirm function is very similar to the JavaScript alert function. A small
dialogue box pops up and appears in front of the web page currently in focus. The confirm
box is different from the alert box. It supplies the user with a choice; they can either press
OK to confirm the popup's message or they can press cancel and not agree to the popup's
request.
If the user clicks "OK", the box returns true. If the user clicks "Cancel", the box returns false.
Syntax
confirm("sometext");
Example
<html>
<head>
<script
type="text/javascript">funct
ion confirmation() {
var answer = confirm("Leave the document") if
(answer){
alert("Bye bye!")
}
else{
alert("Thanks for sticking around!")
}
}
</script>
</head>
<body>
<form>
<input type="button" onclick="confirmation()" value="Leave document">
</form>
</body>
</html>
11. Explain how to work with prompt box with suitable example.
Prompt Box
A prompt box is often used if you want the user to input a value before entering a page.
When a prompt box pops up, the user will have to click either "OK" or "Cancel" to proceed
after entering an input value.
If the user clicks "OK" the box returns the input value. If the user clicks "Cancel" the box
returns null.
Syntax
prompt("sometext","defaultvalue");
Example
var name=prompt("Please enter your name","Harry
Potter"); if (name!=null && name!="")
{
x="Hello " + name + "! How are you today?";
}
2. Which statement is true for VBScript names e.g. variable names or procedure names?
A. They are case sensitive.
B. They are case insensitive.
C. They are case insensitive but should be written consistently for readability.
D. Only variable names are case insensitive.
4. In the Select Case statement, which case is used for unknown cases?
A. Else
B. Default
C. Unknown
D. Not
7. In which of the following scope, variables are available to all the procedures across all the?
A. All of the above
B. Dim
C. Public
D. Private
Skill Level
13. How will you get a combined string from an array of string in VBScript?
A. Using Erase Function
B. Using Join function
C. Using Filter function
D. Using IsArray function
14. How will you format a number upto 3 decimal places in VBScript?
A. Using FormatPercent function
B. Using Log function
C. Using FormatNumberFunction
D. Using Int function
15. How will you trim the leading as well as trailing spaces of a string using VBScript?
A. Using Trim function
B. Using Len function
C. Using Replace function
D. Using Space function
25. How will you get the smallest subscript of an array in VBScript?
A . Using ReDim statement
B . Using LBound function
C . Using UBound function
D . Using Split function
Long Questions
1) How to create variable inVBScript
Dim keyword to tell VBScript you are about to create a variable
Dim nQuantity
Dim Statement
The Dim statement declares and allocates storage space in memory for variables. The Dim
statement is used either at the start of a procedure or the start of a global script block. In the
first case, the variable declared using Dim is local to the procedure. In the second, it's
available throughout themodule.
Syntax
Dim varname[([subscripts])][, varname[([subscripts])]] . . .
.
array1(5) = 16
For i = 0 to ubound(array1)
Msgbox―Value present at index ‖&i&‖ is ―&array1(i) &―<br/>‖Next
</script>
</body>
</html>
Output is:
Value present at index 0 is
hello Value present at index 1
is 12 Value present at index 2
is13
Value present at index 3 is how are
you Value present at index 4 is15
Value present at index 5 is16
Example:
<html>
<head>
<title>Let‘s see implementation of In-Built Array Functions</title>
</head>
<body>
<script language=‖vbscript‖ type=‖text/vbscript‖>
Dimarray1= Array(―January‖,‖February‖,‖March‖,‖April‖)
Dim a , b , c , d , e ,
f a = lbound(array1)
b=
ubound(array1)
c=Split(array1,‖,‖)
d=Join(array1,‖$―)e
=IsArray(array1)
f = Filter(array1,‖J‖)
Msgbox(a)&―<br/>‖M
sgbox(b)&―<br/>‖Msg
box(c)&―<br/>‖Msgb
ox(d)&―<br/>‖Msgbox
(e)&―<br/>‖
Msgbox(f)
</script>
</body>
</html>
Output is:
0
3
January February March April
January $ February $ March $
April True
January
AExit For Statement is used when we want to Exit the For Loop based on certain criteria.
When Exit Foris executed, the control jumps to next statement immediately after the
For Loop.
Syntax
The syntax for Exit ForStatement in VBScript is:
Exit For
Example
The below example uses Exit For. If the value of the Counter reaches 4, the For Loop is Exited
and control jumps to the next statement immediately after the ForLoop.
Example:
<html>
<body>
<script language="vbscript" type="text/vbscript">
Dim a :a=10
For i=0 to a Step 2 'i is the counter variable and it is incremented by 2
document.write("The value is i is : " &i) document.write("<br></br>")
If i=4 Then
i=i*10 'This is executed only if i=4
document.write("The value is i is : " &i) Exit For
'Exited when i=4
End If
Next
</script>
</body>
</html>
When the above code is executed, it prints the following output in the console.
The value is iis :0
The value is iis :2
The value is iis :4
The value is iis :40
Exit Do Statements
An Exit Do Statement is used when we want to Exit the Do Loops based on certain criteria. It
can be used within both Do..Whileand Do..UntilLoops.
When Exit Do is executed, the control jumps to next statement immediately after the Do
Loop. Syntax
The syntax for Exit Do Statement in VBScript is:
Exit Do
Example
The below example uses Exit Do. If the value of the Counter reaches 10, the Do Loop is Exited
and control jumps to the next statement immediately after the ForLoop.
<html>
<body>
<script language="vbscript" type="text/vbscript">
i= 0
Do While i<= 100
If i>10 Then
Exit Do ' Loop Exits if i>10 End
If
document.write("The Value of i is : " &i)
document.write("<br></br>")
i= i+ 2
Loop
</script>
</body>
</html>
When the above code is executed, it prints the following output in the console
The Value of iis :0
The Value of iis :2
The Value of iis :4
The Value of iis :6
The Value of iis :8
The Value of iis :10
For Loop
A for loop is a repetition control structure that allows a developer to efficiently write a loop
that needs to execute a specific number of times.
Syntax
The syntax of a for loop in VBScript is:
For counter = start To end [Step
stepcount][statement 1]
[statement 2]
....
[statement n]
[Exit For]
[statement 11]
[statement 22]
....
[statement n]
Next
Flow Diagram
Here is the flow of control in a For Loop:
The For step is executed first. This step allows you to initialize any loop control
variables and increment the step counter variable.
Secondly, the condition is evaluated. If it is true, the body of the loop is executed. If it
is false, the body of the loop does not execute and flow of control jumps to the next statement
just after the For Loop.
After the body of the for loop executes, the flow of control jumps tothe
Next statement. This statement allows you to update any loop control variables. It is updated
based on the step counter value.
The condition is now evaluated again. If it is true, the loop executes and the process
repeats itself (body of loop, then increment step, and then again condition). After the
condition becomes false, the For Loop terminates.
Example
<html>
<body>
<script language="vbscript" type="text/vbscript">
Dim a : a=10
For i=0 to a Step 2 'i is the counter variable and it is incremented by 2
document.write("The value is i is : " & i) document.write("<br></br>")
Next
</script>
</body>
</html>
When the above code is compiled and executed, it produces the following result:
The value is i is :
0 The value is i is
: 2 The value is i
is : 4 The value is
i is : 6 The value
is i is : 8
The value is i is : 10
Example:
<html>
<body>
<script language="vbscript" type="text/vbscript">
'fruits is an array
fruits=Array("apple","orange","cherries")
Dim fruitnames
'iterating using For each loop
<html>
<body>
<script language="vbscript" type="text/vbscript">
'fruits is an array
fruits=Array("apple","orange","cherries")
Dim fruitnames
'iterating using For each loop.
For each item in fruits
fruitnames=fruitnames&item&vbnewline
Next
msgbox fruitnames
</script>
</body>
</html>
When the above code is executed, it prints all the fruitnames with one item in each line.
Apple
orange
cherries
While condition(s)
[statements 1]
[statements 2]
...
[statements n]
Wend
Example
<html>
<body>
<script language="vbscript" type="text/vbscript">
</script>
</body>
</html>
When the above code is executed, it prints the following output in the console.
The Current Value of the Counter is : 11
The Current Value of the Counter is : 12
The Current Value of the Counter is : 13
The Current Value of the Counter is : 14
The Current Value of the Counter is : 15
11) Explain do….while with syntax and example?
A Do..While loop is used when we want to repeat a set of statements as long as the condition
is true. The Condition may be checked at the beginning of the loop or at the end of the loop.
Syntax
The syntax of a Do..While loop in VBScript is:
Do While condition
[statement 1]
[statement 2]
...
[statement n]
[Exit Do]
[statement 1]
[statement 2]
...
[statement n]
Loop
Example
The below example uses Do..while loop to check the condition at the beginning of the loop.
The statements inside the loop are executed only if the condition becomes True.
<html>
<body>
<script language="vbscript" type="text/vbscript">
Do While i < 5
i=i+1
Document.write("The value of i is : " & i)
Document.write("<br></br>")
Loop
</script>
</body>
</html>
When the above code is executed, it prints the following output in the console.
The value of i is : 1
The value of i is : 2
The value of i is : 3
The value of i is : 4
The value of i is : 5
Alternate Syntax
There is also an alternate Syntax for Do..while loop which checks the condition at the end of
the loop. The Major difference between these two syntax is explained below with an example.
Do
[statement 1]
[statement 2]
...
[statement n]
[Exit Do]
[statement 1]
[statement 2]
...
[statement n]
Loop While condition
Example
The below example uses Do..while loop to check the condition at the end of the loop. The
Statements inside the loop are executed atleast once even if the condition is False.
<html>
<body>
<script language="vbscript" type="text/vbscript">
i=10
Do
i=i+1
Document.write("The value of i is : " & i)
Document.write("<br></br>")
Loop While i<3 'Condition is false.Hence loop is executed once.
</script>
</body>
</html>
When the above code is executed, it prints the following output in the console.
The value of i is : 11
</script>
</body>
</html>
When the above code is executed, it prints the following output in the console.
The value of i is :
11
The value of i is :
12
The value of i is :
13
The value of i is :
14
The value of i is :
15
The value of i is :
16
Alternate Syntax
There is also an alternate Syntax for Do..Until loop which checks the condition at the end of
the loop. The Major difference between these two syntax is explained below with an example.
Do
[statement 1]
[statement 2]
...
[statement n]
[Exit Do]
[statement 1]
[statement 2]
...
[statement n]
Loop Until condition
Example
The below example uses Do..Until loop to check the condition at the end of the loop.
TheStatements inside the loop are executed atleast once even if the condition is True.
<html>
<body>
<script language="vbscript" type="text/vbscript">
i=10
Do
i=i+1
Document.write("The value of i is : " & i)
Document.write("<br></br>")
Loop Until i<15 'Condition is True.Hence loop is executed once.
</script>
</body>
</html>
When the above code is executed, it prints the following output in the console.
The value of i is : 11
UNIT-V
`
BOOTSTRAP
2. Is Bootstrap3 mobile-first?
a. True
b. False
c. Can't say
d. May be
3. Which of the following class in Bootstrap is used to provide a responsive fixed width
container?
a. .container-fixed
b. .container-fluid
c. .container
d. All of the above
a. box
b. .container
c. .container-fluid
d. .jumbotron
6. Which of the following is the correct syntax of creating a standard navigation tab?
9. Which of the following class in Bootstrap is used to create a basic list group?
a. .grouped-list
b. .select-list
c. .list-group
d. .list-grouped
a. .img-rounded
b. .img-circle
c. .img-rounded
d. None of the above
11. Which of the following class in Bootstrap is used to add a zebra-stripe to a table?
a. .tab-striped
b. .zebra-strip
c. .table-stripped
d. .table-striped
12. Which of the following class in Bootstrap is used to create a large button?
a. .btn-xl
b. .btn-lrg
c. .btn-large
d. .btn-lg
13. Which of the following plugin in Bootstrap is used to create a modal window?
a. popup
b. alert
c. modal
d. window
14. Which of the following class in Bootstrap is used to create basic pagination?
a. .page
b. .pagin
c. .paginate
d. .pagination
a. tag
b. .badge
c. .page
d. .flag
16. The class in Bootstrap used to provide rounded corners to the image is -
a. .img-circle
b. .image-circle
c. .image-rounded
d. .img-rounded
a. .panel
b. .container
c. .box
d. .jumbotron
a. carousel
b. .collapse
c. .pager
d. None of the above
19. The class in Bootstrap which is used to specify the collapsible elements is -
a. .collapse
b. .carousel
c. .pager
d. None of the above
a. .wel
b. .well
c. .well-container
d. .container-well
21. The class used for creating the large size wells is -
a. .well-large
b. .well-big
c. .well-lg
d. .well-sm
22. The class used for creating the small size wells is -
a. .well-small
b. .well-short
c. .well-lg
d. .well-sm
23. Which of the following class in Bootstrap is used for creating the large size modals?
a. .modal-large
b. .modal-sm
c. .modal-big
d. .modal-lg
a. popover
b. tooltip
c. modal
d. None of the above
25. Which of the following is the correct syntax to insert search icon?
Bootstrap is simple to use and anyone with a basic understanding of HTML and CSS
can get started.
Features that adapt to phones, tablets, and desktops: Bootstrap's responsive CSS
adapts to phones, tablets, and desktops.
A mobile-first strategy: Mobile-first styles are built into the Bootstrap framework.
Bootstrap 4 is compatible with all modern browsers, including Chrome, Firefox,
Internet Explorer 10+, Edge, Safari, and Opera.
A bootstrap container is a handy class that generates a central region on the page where we
can put our site content. The bootstrap .container has the advantage of being responsive and
containing all of our other HTML code. Containers are used to pad the content within them,
and there are two types of containers:
The Bootstrap Grid System is a mobile-first, responsive grid system that scales up to 12
columns as the device or viewport size grows. Predefined classes for quick layout options
and powerful mix-ins for creating successful semantic layouts are included in the system.
.col- for extra small devices, whose screen width is less than 576px.
.col-sm- small devices, whose screen width is equal to or greater than 576px.
.col-md- medium devices, whose screen width is equal to or greater than 768px.
.col-lg- large devices, whose screen width is equal to or greater than 992px.
.col-xl- extra large devices, whose screen width is equal to or greater than 1200px.
The classes listed above can be combined to build layouts that are more dynamic and
adaptable.
4. Write a note on Button group and breadcrumb in Bootstrap?
Button group:
Multiple buttons can be placed together on a single line using button grou
groups. You
can use this to group objects together, such as alignment buttons.
The .btn-group
group class is used for basic button groups. You can use the class .btn to
wrap a set of buttons in .btn
.btn-group.
Breadcrumbs:
5. In Bootstrap, what are the two codes for displaying code? What is alead?
Lead adds some emphasis to a paragraph. The .lead class is used to achieve this and it
makes the font larger, taller, and lighter in weight.
Create a wrapper <div> and add a class of .alert and one of the contextual classes to create
a basic alert (e.g., .alert-success, .alert-info, .alert-warning, .alert-danger, .alert-primary,
.alert-secondary, .alert-light or .alert-dark).
Bootstrap Card:
In Bootstrap 4, a card is a bordered box with padding surrounding its content. It has options
for headers, footers, content, and colors, among other things.
<div class="card">
<div class="card-header">Header</div>
<div class="card-body">Body</div>
<div class="card-footer">Footer</div>
</div>
Another example:
<div class="card" style="width:400px">
<img class="card-img-top" src="img_avatar.png" alt="Card image">
<div class="card-body">
<h4 class="card-title">Richard Taylor</h4>
<p class="card-text">Some example text.</p>
<a href="#" class="btnbtn-primary">See Profile</a>
</div>
</div>
7. Discuss Bootstrap table and various classes that can change the appearance of the table.
If your website has lots of pages, you might require adding some sort of pagination to each
page.
<ul class="pagination">
<li class="page-item"><a class="page-link" href="#">Previous</a></li>
<li class="page-item"><a class="page-link" href="#">1</a></li>
<li class="page-item"><a class="page-link" href="#">2</a></li>
<li class="page-item"><a class="page-link" href="#">3</a></li>
<li class="page-item"><a class="page-link" href="#">4</a></li>
<li class="page-item"><a class="page-link" href="#">Next</a></li>
</ul>
Pagination is how Bootstrap handles an unordered list. The following classes are provided
by bootstrap to manage pagination:
.disabled, .active: Use .disabled for unclickable links and .active to indicate the current
page when customising links.
Badges are used to supplement any content with additional information. To make
rectangular badges, use the .badge class with a contextual class (like .badge-secondary)
within <span> elements. It's worth noting that badges scale to fit the parent element's size
(if any).
When the user moves the mouse pointer over an element, the Tooltip component appears as
a little pop-up box. The Popover component is a pop-up box that emerges when the user
clicks on an element. The popover may hold a lot more information.
The popover will show on the right side of the element by default whereas the tooltip will
show on the top of the element by default.
12. What classes can help you change the default settings of positioning a popover and
closing a popover?
The popover will show on the right side of the element by default.
To position the popover on the top, bottom, left, or right side of the element, use the
data-placement attribute.
When you click on the element again, the popover closes by default.
However, the data-trigger="focus" attribute can be used to close the popover when
the user clicks outside the element.
Use the data-trigger attribute with the value "hover" if you want the popover to
appear when you move the mouse cursor over the element.