Rescued Document
Rescued Document
Rescued Document
Output:
CSS Practical Code Practice
Experiment No. 2:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body> <script> var a = 30; if (a
> 25) { document.write("Number is greater
than 25");
} else if (a < 20) {
document.write("Number is less than 20");
} else { document.write("Number is greater than 20 and
less than 25");
}
</script>
</body>
</html>
Output :
CSS Practical Code Practice
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body> <script> document.write("Odd
numbers upto 20 : <br>"); for (var i = 0; i
< 21; i++) { if (i % 2 != 0) {
document.write(" " + i + "<br>");
}
}
</script>
</body>
</html>
Output :
CSS Practical Code Practice
Another way:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body> <script> document.write("Odd
numbers upto 20 : <br>"); var text = "<table
border=1px><tr>"; for (var i = 0; i < 21; i+
+) { if (i % 2 != 0) { text +=
"<td>" + i + "</td></tr>";
} }
text += "</table>";
document.write(text);
</script>
</body>
</html>
Output:
CSS Practical Code Practice
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body> <script> var num1 = 22; var num2 =
13; document.write("First Number :" + num1);
document.write("<br>Second Number :" + num2);
document.write("<br><br>Addition is : " + (num1 + num2));
document.write("<br>Subtraction is : " + (num1 - num2));
document.write("<br>Multiplication is : " + num1 * num2);
document.write("<br>Division is : " + num1 / num2);
</script>
</body>
</html>
Output:
CSS Practical Code Practice
Output :
CSS Practical Code Practice
-
Q.5 : Create and access object properties to solve the given properties.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body> <script>
var stud = {
fname: "Shreyas",
lname: "Shinde",
roll: 233230,
}; document.write("First Name :" + stud.fname);
document.write("<br>Last Name :" + stud["lname"]);
document.write("<br>Full Name :" + stud.fname + " " + stud["lname"]);
document.write("<br>Roll Number :" + stud.roll);
</script>
</body>
</html>
Output:
CSS Practical Code Practice
Q.1 :-
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body> <script> var arr = new Array(12, 33, 22, 13, 70,
59, 349, 342, 123, 1322); document.write("Array contains :" +
arr); var max = arr[0]; for (i = 1; i < arr.length; i++) {
if (max < arr[i]) { max = arr[i];
} } document.write("<br>Largest number form this
array is :" + max);
</script>
</body>
</html>
Output :
CSS Practical Code Practice
Q.2 :-
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body> <script> var arr = ["Apple", "Mango",
"Pineapple", "Banana"]; document.write("Stack contains :"
+ arr); arr.push("Orange");
document.write("<br><br>Insertion in stack :" + arr); var
del = arr.pop(); document.write("<br><br>Deletion of
element :" + arr); document.write("<br>Deleted element
from last is :" + del);
</script>
</body>
</html>
Output :
CSS Practical Code Practice
Experiment No. 4:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body> <script> function funWithArg(fnm,
lnm, roll) { document.write("Full Name :" + fnm
+ " " + lnm); document.write("<br>Roll
Number :" + roll);
} funWithArg("Shreyas", "Shinde",
233230);
</script>
</body>
</html>
Output :
CSS Practical Code Practice
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body> <script> var ans = first();
function first() { var fullnm = second("Shreyas",
"Suresh", "Shinde"); return fullnm;
} function second(fnm, mnm,
lnm) { return fnm + " " + mnm + "
" + lnm;
} document.write("Full Name is :
" + ans);
</script>
</body>
</html>
Output :
CSS Practical Code Practice
Experiment No. 5 :
Output :
CSS Practical Code Practice
<!DOCTYPE html>
<html lang="en">
<head>
<title>Document</title>
</head> <script> function check() { var ans =
sub.options[sub.selectedIndex].value;
document.getElementById("p1").innerHTML = "You Selected " + ans;
}
</script>
<body>
<form action="">
<center>
<h1>Option List Example</h1>
<br />
<select name="sub" id="sub" onchange="check()">
<option value="" hidden>Select Here</option>
<option value="AJP">AJP</option>
<option value="OSY">OSY</option>
<option value="CSS">CSS</option>
<option value="EST">EST</option>
<option value="STE">STE</option>
</select>
<p id="p1"></p>
</center>
</form>
</body> </html>
Output :
CSS Practical Code Practice
Experiment No. 6:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head> <script> function
clickon() { p1.innerHTML =
"Mouse Clicked";
} function over() {
p1.innerHTML = "Mouse Over";
}
</script>
<body> <input
type="button"
value="Try Here"
onclick="clickon()"
onmouseover="over()"
/>
<p id="p1"></p>
</body>
</html>
Output :
CSS Practical Code Practice
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head> <script>
function clearit() {
ans.value = " ";
} function
addval(val) {
ans.value += val;
} function solve() {
ans.value = eval(ans.value);
}
</script>
<body>
<center>
<table border="1px">
<tr>
<td colspan="3">
<input type="text" name="" id="ans" />
</td>
<td>
<input type="button" value="C" onclick="clearit()" />
</td>
</tr>
<tr>
<td align="center">
<input type="button" value="1" onclick="addval('1')" />
</td>
<td align="center">
<input type="button" value="2" onclick="addval('2')" />
</td>
<td align="center">
<input type="button" value="3" onclick="addval('3')" />
</td>
<td align="center">
<input type="button" value="/" onclick="addval('/')" />
</td>
</tr>
<tr>
<td align="center">
<input type="button" value="4" onclick="addval('4')" />
</td>
<td align="center">
CSS Practical Code Practice
Output :
CSS Practical Code Practice
Experiment No.7 :
Output :
-
Q.2 : Develop a JavaScript to demonstrate change attribute value dynamically.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body> <img
src="Exp2_St5_css.png"
alt="Code image"
width="200"
height="230"
id="MyImg" />
<br /><br />
Click on button to change attribute values
<br />
<input type="button" value="Click Here" onclick="change()" />
<p id="p1"></p> <script> function
change() { var x =
document.getElementById("MyImg");
x.attributes["src"].value = "Exp2_St5_OP.png";
x.attributes["height"].value = 300;
x.attributes["width"].value = 350;
x.attributes["alt"].value = "Output Image";
callit();
} function callit() { var txt = ""; var x
= document.getElementById("MyImg"); for (var i = 0; i < 5; i+
+) { txt += x.attributes[i].name + " = " +
x.attributes[i].value +
"<br>"; }
document.getElementById("p1").innerHTML = txt;
}
callit();
</script>
</body>
</html>
CSS Practical Code Practice
Output :
CSS Practical Code Practice
Output :
CSS Practical Code Practice
Experiment No. 8 :
Output :
-
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head> <script> function create() {
var x = document.createElement("SELECT");
var op1 = document.createElement("OPTION");
op1.setAttribute("value", "Sub1"); var
txt1 = document.createTextNode("AJP");
op1.appendChild(txt1); var op2 =
document.createElement("OPTION");
op2.setAttribute("value", "Sub2"); var
txt2 = document.createTextNode("CSS");
op2.appendChild(txt2);
x.appendChild(op1);
x.appendChild(op2);
document.body.append(x);
}
</script>
<body>
<b>Click on button to create option list dynamically</b>
<br /><br />
<input type="button" value="Create" onclick="create()" />
</body>
</html>
Output :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body> <script> document.write("isNaN(123) : " + isNaN(123));
document.write("<br>isNaN('abc') : " + isNaN("abc"));
document.write("<br>isInteger('abc') : " + Number.isInteger("abc"));
document.write("<br>isInteger(123) : " + Number.isInteger(123));
document.write("<br>isFinite(-0.10000) : " + Number.isFinite(-0.1));
document.write("<br>isFinite(0/0) : " + Number.isFinite(0 / 0));
document.write("<br>eval(22-13) : " + eval(22 - 13));
document.write("<br>parseInt('99') : " + parseInt("99"));
document.write("<br>parseFloat('99.1234') : " + parseFloat("99.1234"));
</script>
</body>
</html>
Output :
CSS Practical Code Practice
Experiment No. 9:
Output :
CSS Practical Code Practice
Q.2 :- Develop JavaScript to create cookies with different attributes such as Expiration,
MaxAge and Path.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head> <script> function setCookie() {
var cval = escape(document.form1.val.value); var
now = new Date(); document.cookie = "name=" +
cval; now.setMonth(now.getMonth() + 1);
document.cookie = "expires=" + now.toUTCString();
document.cookie = "path=/"; document.cookie =
"max-age=" + 30 * 24 * 60 * 60;
document.write("Setting Cookie with : " + document.cookie);
}
</script>
<body>
<form action="#" name="form1">
Enter Cookie value :
<input type="text" name="val" id="val" />
<br /><br />
<input type="button" value="SetCookie" onclick="setCookie()" />
</form>
</body>
</html>
Output :
Q.3 :- Develop a JavaScript to change background colour of parent window from cookie. *
Make sure all cookies are deleted
CSS Practical Code Practice
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head> <script> function setit() { var
colour = document.getElementById("col").value;
document.cookie = "Color=" + colour;
} function change() { var
arr = document.cookie.split("=");
document.bgColor = arr[1];
}
</script>
<body>
Select your favourite color :
<select name="col" id="col" onchange="setit()">
<option value="RED">RED</option>
<option value="orange">ORANGE</option>
<option value="GRAY">GRAY</option>
<option value="PURPLE">PURPLE</option>
</select>
<input type="button" value="Change Color" onclick="change()" />
</body>
</html>
Output :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head> <script>
function acc() { for
(prop in window) {
document.write("<br>" + prop);
}
}
</script>
<body>
<input type="button" value="Access window properties" onclick="acc()" />
</body>
</html>
Output :
Some of them;
Q.2 :- Develop JavaScript to open different window with different URL and Features.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
CSS Practical Code Practice
Output :
CSS Practical Code Practice
Q.3 :- Develop a JavaScript to change background colour of parent window from child
windows.
Child Program :
CSS Practical Code Practice
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head> <script>
function change() {
document.bgColor = "gray";
parent.document.bgColor = "orange";
}
</script>
<body>
<h2>This is a child window</h2>
Click on button to change background color of parent window <br /><br />
<input type="button" value="Try it.." onclick="change()" />
</body>
</html>
Parent Program :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<iframe src="Exp10_3_Child.html" frameborder="1">
If your browser can't understand iframe the this message will be
displayed
</iframe>
<h2>This is a parent window Containing 1 child window</h2>
</body>
</html>
Output :
CSS Practical Code Practice
Experiment No. 11 :
Q.1 :- Write a JavaScript to display index of matching string inside input string.
<!DOCTYPE html>
<html lang="en">
CSS Practical Code Practice
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head> <script> function check() { var
str = document.getElementById("inp").value; var
pattern = document.getElementById("pat").value;
var patt = new RegExp(pattern, "g"); var ind =
str.search(patt);
document.getElementById("p").innerHTML =
"Your search string is at index : " + ind;
}
</script>
<body>
Enter Input String :
<input type="text" name="inp" id="inp" />
<br /><br />
Enter Search String :
<input type="text" name="pat" id="pat" />
<br /><br />
<input type="button" value="Find Index" onclick="check()" />
<br /><br />
<p id="p"></p>
</body>
</html>
Output :
Output :
Q.3 :- Develop a JavaScript to apply different regular expression for student profile Form.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
CSS Practical Code Practice
if (
AJP.checked != true &&
Css.checked != true &&
OSY.checked != true &&
STE.checked != true
) { document.getElementById("sub_err").innerHTML = "Select
subject here";
} else {
document.getElementById("sub_err").innerHTML = "OK"; }
if (FY.checked != true && SY.checked != true && TY.checked != true) {
} else {
document.getElementById("br_err").innerHTML = "OK";
}
}
</script>
<body>
<center>
<h2>Student Profile Page</h2>
<table>
<tr>
<td>First name:</td>
<td><input type="text" id="first_name" /></td>
<td>
<p id="name_err"></p>
</td>
</tr>
<tr>
<td>User name:</td>
<td><input type="text" id="username" /></td>
<td>
<p id="uname_err"></p>
</td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" id="password" /></td>
<td>
<p id="pass_err"></p>
</td>
</tr>
<tr>
<td>Email_id :</td>
<td><input type="text" id="address" /></td>
<td>
<p id="email_err"></p>
</td>
</tr>
<tr>
<td>Subject:</td>
<td>
</td>
<td>
<p id="sub_err"></p>
</td>
</tr>
<tr>
<td>Year:</td>
<td>
<input type="radio" name="subject" id="FY" value="FY" /> FY
<input type="radio" name="subject" id="SY" value="SY" /> SY
<input type="radio" name="subject" id="TY" value="TY" /> TY
</td>
<td>
<p id="ace_year_err"></p>
</td>
</tr>
<tr>
<td>Branch:</td>
<td>
<select id="dropdown" onchange="validate()">
<option value="-1" selected="true">Select Branch</option>
<option value="Civil Engineering">Civil Engineering</option>
<option value="Computer Engineering">Computer
Engineering</option>
<option value="Electrical Engineering">
Electrical Engineering
</option>
<option value="Mechanical Engineering">
Mechanical Engineering
</option>
<option value="Electronics Engineering">
Electronics Engineering
</option>
</select>
</td>
<td>
<p id="br_err"></p>
</td>
</tr>
<tr>
<td float="center">
<input type="button" onclick="validate()" value="Submit" />
</td>
</tr>
</table>
</center>
</body>
</html>
CSS Practical Code Practice
Output :
CSS Practical Code Practice
CSS Practical Code Practice
Output :
CSS Practical Code Practice
Output :
CSS Practical Code Practice
1. popup menu:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<style>
.dropdownbtn { background-
color: cornflowerblue; color:
#fff; padding: 16px;
border: none; font-size: 16px;
}
.dropmenu {
position: relative;
display: inline-block;
}
.dropdownbtn:hover {
background-color: darkcyan;
}
.menucontent {
display: none; background-
color: darkgray; min-
width: 115px; position:
absolute; z-index: 1;
}
.menucontent a {
color: #fff;
padding: 16px, 25px;
display: block;
}
.menucontent a:hover {
background-color: aliceblue;
color: black;
}
.show {
display: block;
}
</style>
<body>
<h2>Clickable Dropdown</h2>
<p>Click on the button to open the dropdown menu.</p>
<div class="dropmenu">
CSS Practical Code Practice
Output :
2. Sliding menu :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<style> .sliding {
CSS Practical Code Practice
Output :
Experiment No. 14 :
:
CSS Practical Code Practice