Css
Css
Instructions:
(1) All questions are compulsory.
(2) Illustrate your answers with neat sketches wherever necessary.
(3) Figures to the right indicate full marks.
(4) Assume suitable data if necessary.
(5) Preferably, write the answers in sequential order.
1
student.class="Fifth";
document.write("Student Id= "+student.id)
document.write("<br/>")
document.write("Student Class= "+student.class)
document.write("<br/>")
document.write("Student Name= "+student.name)
</script>
</head>
<body>
</body>
</html>
Operator Descryption Eg
&&(Logical AND Operator) If the both operands are zero then the (A && B) is true.
condition becomes true.
|| (Logical OR Operator) If any of the operands are zero then the (A || B) is true.
condition becomes true.
! (Logical NOT Operator) Use to reverses the logical state of its ! (A && B) is flase.
operand. If a condition is true then
Logical NOT operator will make false.
d) Write a JavaScript that initializes an array called “Fruits” with names of five fruits.
The script then displays the array in a message box.
Ans: -
e) Give syntax of and explain the use of “with” statement/clause in JavaScript using
suitable example.
Ans: -
f) Enlist and explain the use of any two Intrinsic JavaScript functions.
Ans: -
2
g) State and explain what is a session cookie?
Ans: -
1. A session cookie contains information that is stored in a temporary
memory location and then subsequently deleted after the session is
completed or the web browser is closed. This cookie stores information
that the user has inputted and tracks the movements of the user within
the website.
2. A session cookie is also known as transient cookie.
Q.2) Attempt any THREE of the following. 12 Marks
a) Write syntax of and explain prompt method in JavaScript with the help of suitable
example.
<head>
<title>
Window prompt() Method
</title>
</head>
<button onclick="geek()">
Click me!
</button>
<p id="g"></p>
<script>
function geek() {
var doc = prompt("Please enter some text",
"GeeksforGeeks");
if (doc != null) {
document.getElementById("g").innerHTML =
"Welcome to " + doc;
}
}
</script>
</body>
</html>
1. The prompt() method is used to display a dialog with an optional message
prompting the user to input some text. It is often used if the user wants to input a
value before entering a page.
2. It returns a string containing the text entered by the user, or null.
3
b) Write a JavaScript program which compute, the average marks of the following
students Then, this average is used to determine the corresponding grade.
Student Name Marks
Advait 80
Anay 77
Manyata 88
Saanvi 95
Saachi 68
function myFunction()
{
//get the value from textbox
var str = document.getElementById('txtbox').value;
function checkPalindrome(str)
{
var orignalStr;
4
str = str.join(''); //then join the reverse order array values
5
var count = 0, total_vowels="";
for (var i = 0; i < str.length; i++) {
if (str.charAt(i).match(/[a-zA-Z]/) != null) {
// findVowels
if (str.charAt(i).match(/[aeiouAEIOU]/))
{
total_vowels = total_vowels + str.charAt(i);
count++;
}
}
}
document.getElementById('vowels').value = total_vowels;
document.getElementById('vcount').value = count;
}
</script>
</head>
<body>
<div >
<table border="1px" cellspacing="0" width="30%" style="background-color: #FF6600; color:White">
<tr><td colspan="2" align="center"><b>Get Vowels from String</b></td></tr>
<tr>
<td>Enter Text :</td>
<td><input type='text' id='txtname' /></td>
</tr>
<tr>
<td>Vowels Count :</td>
<td><input type='text' readonly="readonly" id='vcount'/></td>
</tr>
<tr>
<td>Total Vowels :</td>
<td><input type='text' readonly="readonly" id='vowels' /></td>
</tr>
<tr>
<td></td>
<td><input type='button' value='Get Vowels Count' onclick="javascript:GetVowels();" /></td>
</tr>
</table>
</div>
</body>
</html>
6
c) Write a JavaScript that find and displays number of duplicate values in an array.
Ans: -
d) Write a function that prompts the user for a color and uses what they select to set the
background color of the new webpage opened .
Ans: -
<!DOCTYPE HTML>
<html>
<head>
<title>
How to change the background color
after clicking the button ?
</title>
</head>
<script>
var el_up = document.getElementById("GFG_UP");
var el_down = document.getElementById("GFG_DOWN");
var str = "Click on button to change the background color";
el_up.innerHTML = str;
function changeColor(color) {
document.body.style.background = color;
}
function gfg_Run() {
changeColor('yellow');
el_down.innerHTML = "Background Color changed";
}
</script>
</body>
</html>
7
Q.4) Attempt any THREE of the following. 12 Marks
a) State what is a regular expression? Explain its meaning with the help of a suitable
example.
Ans: -
1. a regular expression is a pattern of characters.
2. JavaScript regular expression are object.
3. When you create a regular expression, you test the regular expression against a
string.
4. Regular expression is a series of characters between two forward slashes(/……/).
5. for e.g., the regular expression /green/ might be matched against the string, “The
green grass”.
6. if green is contained in the string, then there is a successful match.
b) Write a webpage that accepts Username and adharcard as input texts. When the user
enters adhaarcard number ,the JavaScript validates card number and diplays whether
card number is valid or not. (Assume valid adhaar card format to be nnnn.nnnn.nnnn
or nnnn-nnnn-nnnn).
Ans: -
c) Write the syntax of and explain use of following methods of JavaScript Timing Event.
a. setTimeout()
b. setInterval()
d) Develop JavaScript to convert the given character to Unicode and vice versa.
Ans: -
e) List ways of Protecting your webpage and describe any one of them.
Ans: -
1. Keep software up to date
2. Beware of error messages
3. Check your passwords
4. Avoid file uploads
5. Use HTTPS
6. Get website security tools
8
Q.5) Attempt any TWO of the following. 12 Marks
a) Write HTML Script that displays textboxes for accepting Name, middlename,
Surname of the user and a Submit button. Write proper JavaScript such that when the
user clicks on submit button
i) all texboxes must get disabled and change the color to “RED”. and with
respective labels.
FRAME2 FRAME3
• FRUITS
• FLOWERS
• CITIES
Fruits, Flowers and Cities are links to the webpage fruits.html, flowers.html,
cities.html respectively. When these links are clicked corresponding data appears in
“FRAME3”.
9
Ans: -
c) Create a slideshow with the group of four images, also simulate the next and previous
transition between slides in your JavaScript.
Ans: -
Scheme – I
Sample Test Paper - I
Program Name : Diploma in Engineeering Group
Program Code : CO / CM / CW / IF Semester :
Fifth Course Title : Clint Side Scripting Language (Elective)
Marks
Time: 1 Hour
: 20 22519
Instructions:
(1) All questions are compulsory.
(2) Illustrate your answers with neat sketches wherever necessary.
(3) Figures to the right indicate full marks.
(4) Assume suitable data if necessary.
(5) Preferably, write the answers in sequential order.
10
Properties defined by getter and setters are known as accessor
properties.
Accessor property generates its value dynamically when being
accessed or set.
11
i. charCodeAt()
ii. fromCharCode()
Scheme – I
Sample Test Paper - II
Program Name : Diploma in Engineeering Group
Program Code : CO / CM / CW / IF Semester :
Fifth Course Title : Clint Side Scripting Language (Elective)
Marks
Time: 1 Hour
: 20 22519
Instructions:
(1) All questions are compulsory.
(2) Illustrate your answers with neat sketches wherever necessary.
(3) Figures to the right indicate full marks.
(4) Assume suitable data if necessary.
(5) Preferably, write the answers in sequential order.
FRAME2
FRAME3
12
Ans: -
13