Practical Sanket Css13
Practical Sanket Css13
Client Side Scripting languages (22519) for the academic year ................. to
Seal of Institution
Content Page
Total
PRACTICAL 1
CODE :-
<html>
<head><title>Arithmetic evaluation & Message Printing</title>
<body>
<script type="text/javascript">
</script>
</body>
</head>
</html>
OUTPUT :-
CONCLUSION :-
In this practical I successfully created a webpage to
implement arithmetic evaluation and message printing.
CODE :-
<html>
<head><title>PR 1 Decision Making Statement & Looping Statement</title>
<body>
<script type="text/javascript">
</script>
</body>
</head>
</html>
OUTPUT :-
CODE :-
<html>
<head><title>PR 1 Decision Making Statement & Looping Statement</title>
<body>
<script type="text/javascript">
for(var i=1;i<=10;i++)
{
document.write("<br>"+num+" * "+i+" = "+(num*i));
}
</script>
</body>
</head>
</html>
OUTPUT :-
CONCLUSION :-
In this practical I successfully applied Decision Making &
Looping Statements to develop s JavaScript.
CODE :-
<html>
<head><title>PR 2 Array Functionalities</title>
<body>
<h1>Array Functionalities</h1>
<script type="text/javascript">
arr.push("AJP", 90.71);
document.write("<b>After using push('AJP', 90.71) array will be :-</b> " +
arr + "<br>");
var e1 = arr.pop();
document.write("<b>After using pop() array will be :-</b> " + arr +
"<br><b>(Here, deleted element is :- " + e1 + ")<br></b>");
arr.unshift(53, "Sanket");
document.write("<b>After using unshift(53, 'Manav') array will be :-</b> " +
arr + "<br>");
var e2 = arr.shift();
document.write("<b>After using shift() array will be :-</b> " + arr +
"<br><b>(Here, deleted element is :- " + e2 + ")<br></b>");
var arr2 = [70, false, "MAD"];
var new_array = arr.concat(arr2);
document.write("<b>After using concat([70, false, 'MAD']) array will be :-
</b> " + new_array + "<br>");
num_arr.reverse();
document.write("<b>After using reverse() on Number's array it will be :-
</b> " + num_arr + "<br>");
num_arr.sort();
document.write("<b>After using sort() on Number's array it wil be :-</b> " +
num_arr + "<br>");
</script>
</body>
</head>
</html>
OUTPUT :-
CONCLUSION :-
In this practical I successfully applied and demonstrate
Array Functionalities to develop a JavaScript.
CODE :-
<html>
<head><title>PR 3 Implementation of Function</title>
<body>
<script type="text/javascript">
function factorial(n)
{
if (n === 0 || n === 1)
{
return (1);
}
else
{
return (n * factorial(n - 1));
}
}
</script>
</body>
</head>
</html>
OUTPUT :-
CONCLUSION :-
In this practical I successfully implement Functions to
develop a JavaScript.
CODE :-
<html>
<head><title>Form Elements Demo</title>
</head>
<body>
<form action="">
Enter User name:<br>
<input type="text" name="uid"><br>
Enter User password:<br>
<input type="password" name="upass"><br>
</form>
</body>
</html>
OUTPUT :-
CONCLUSION :-
In this practical I successfully created a webpage using
some different Form Elements.
CODE :-
<html>
<head>
<title>Form Event Demo</title>
<script>
function display()
{
var v1 = "No Bike";
var v2 = "No Car";
if (document.form1.v1.checked)
{
v1 = document.form1.v1.value;
}
if (document.form1.v2.checked)
{
v2 = document.form1.v2.value;
}
document.write("<body style='background-color:orange'>"+
"<b>Your Info as per Form</b><br>" +
"<br><b><i>Username:</i></b> " + document.form1.uid.value +
"<br><b><i>Password:</i></b> " + document.form1.upass.value +
"<br><b><i>Gender:</i></b> " + document.form1.gender.value +
"<br><b><i>Vehicles:</i></b> " + v1 + ", " + v2);
}
function submit_msg()
{
alert("Form submitted successfully..!");
display();
}
function reset_msg()
{
alert("Form cleared..!");
}
function gender_msg()
{
alert("You've selected :- " + document.form1.gender.value);
}
</script>
</head>
<body>
<form action="" name="form1" onsubmit="submit_msg()"
onreset="reset_msg()">
Enter User name:<br>
<input type="text" name="uid"><br>
CODE :-
<html>
<head>
<title>New Survey Form</title>
<script>
var key_pressed_once = false;
function show_favorite_color()
{
alert("You selected: " + document.form2.color.value);
}
function submit_survey()
{
alert("Survey submitted successfully!");
display_info();
}
function reset_survey()
{
alert("Survey reset!");
key_pressed_once = false;
}
function display_info()
{
document.write("<body style='background-color:lightblue'>" +
"<b>Your Survey Information:</b><br>" +
"<br><b><i>Username:</i></b> " +
document.form2.username.value +
"<br><b><i>Favorite Color:</i></b> " +
document.form2.color.value +
"<br><b><i>Feedback:</i></b><br>" +
document.form2.feedback.value);
}
function key_pressed()
{
if (!key_pressed_once)
{
alert("You pressed a key in the feedback section!");
key_pressed_once = true;
}
}
function mouse_over_submit()
{
alert("You're about to submit the survey!");
}
</script>
</head>
<body>
<form action="" name="form2">
Enter Username:<br>
<input type="text" name="username"><br>
OUTPUT :-
CONCLUSION :-
In this practical I successfully created a webpage
implementing some different Form Events like onclick, onchange,
onkeypress.
CODE
<html>
<head>
<title>Using Intrinsic JavaScript Functions</title>
</head>
<body>
<FORM name="contact" action="#" method="post">
<P>
First Name: <INPUT type="text" name="Fname"/> <BR>
Last Name: <INPUT type="text" name="Lname"/><BR>
Email: <INPUT type="text" name="Email"/><BR>
<img src="submit.jpg"
onclick="javascript:document.forms.contact.submit()"/>
<img src="reset.jpg"
onclick="javascript:document.forms.contact.reset()"/>
</P>
</FORM>
</body>
</html>
Output :-
CONCLUSION :-
In this practical I successfully applied and demonstrate
implement intrinsic java functions.
CODE
<html>
<head>
<script type = "text/javascript">
function WriteCookie() {
if(document.myform.customer.value == "" )
{
alert("Enter some value!");
return;
}
cookievalue = escape(document.myform.customer.value) + ";";
document.cookie = "name=" + cookievalue;
document.write ("Setting Cookies : " + "name=" + cookievalue );
}
</script>
</head>
<body>
<form name = "myform" >
Enter name: <input type = "text" name = "customer"/>
<input type = "button" value = "Set Cookie" onclick = "WriteCookie();"/>
</form>
</body>
</html>
Output:-
CONCLUSION :-
In this practical I successfully applied and demonstrate
implement creating session and persistent cookies.
CODE
<!DOCTYPE html>
<html>
<body>
<p>Click the button to open an about:blank page in a new browser window that
is 200px wide and
100px tall.</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction()
{
var myWindow = window.open("", "", "width=200,height=100");
}
</script>
</body>
</html>
Output:-
CODE
<!DOCTYPE html>
<html>
<body>
<p>Click the button to open an about: Google page in a new browser window
that is 200px wide and 200px tall.</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction()
{
var myWindow = window.open("http://google.com/", "Google",
"width=200,height=200");
}
</script>
</body>
</html>
Output:-
CONCLUSION :-
In this practical I successfully applied and demonstrate
implement placing the window on the screen and working with child window.
CODE
<!DOCTYPE html>
<html lang="en">
<head>
<button type="submit">Submit</button>
</form>
<div id="result"></div>
<script>
function validateForm() {
isValid = true;
if (!nameRegex.test(name)) {
document.getElementById('nameError').textContent = "Please enter a valid
name (at least 3 letters)."; isValid =
false;
} else { document.getElementById('nameError').textContent =
"";
}
if (!phoneRegex.test(phone)) {
document.getElementById('phoneError').textContent = "Please enter a
valid 10-digit phone number.";
isValid = false;
} else { document.getElementById('phoneError').textContent =
"";
}
if (isValid) {
document.getElementById('result').textContent = `Name: ${name}, Phone
Number: ${phone}`;
}
return false;
}
</script>
</body>
</html>
Output:-
CONCLUSION :-
CODE
<html>
<head>
<title>Pulldown Menu Example</title>
<script>
function displayPage(ch)
{
page = ch.options[ch.selectedIndex].value
if(page != "")
{
window.location = page
}
}
</script>
</head>
<body>
<form name='form1' action="#">
Select your favourite website:
<select name="mymenu" onchange="displayPage(this)">
<option value="https://www.google.com">Google</option>
<option value="https://www.yahoo.com">Yahoo</option>
<option value="https://www.msbte.org.in">MSBTE</option>
</select>
</form>
</body>
</html>
Output:-
CODE
<html>
<head>
<title>Context Menu Example</title>
<style>
.menu {
width: 150px;
border-style: solid;
border-width: 1px;
border-color: grey;
position: fixed;
display: none;
}
.menu-item {
height: 20px;
}
.menu-item:hover {
background-color: #6CB5FF;
cursor: pointer;
}
</style>
<script>
var menuDisplayed = false
function showMenu()
{
var left = arguments[0].clientX
var top = arguments[0].clientY
menuBox = window.document.querySelector('.menu')
menuBox.style.left = left + 'px'
menuBox.style.top = top + 'px'
menuBox.style.display = 'block'
arguments[0].preventDefault()
menuDisplayed = true
}
function hideMenu()
{
if(menuDisplayed == true) {
menuBox.style.display = 'none'
}
}
</script>
</head>
<body>
</h2>Right click mouse to view Context Menu</h2>
<div class="menu">
<div class="menu-item">Google</div>
<div class="menu-item">Facebook</div>
<hr>
<div class="menu-item">MSN</div>
<div class="menu-item">Bing</div>
</div>
</body>
</html>
<html>
<head>
<title>Context Menu Example</title>
<style>
.menu {
width: 150px;
border-style: solid;
border-width: 1px;
border-color: grey;
position: fixed;
display: none;
}
.menu-item {
height: 20px;
}
.menu-item:hover {
background-color: #6CB5FF;
cursor: pointer;
}
</style>
<script>
var menuDisplayed = false
var menuBox = null
window.addEventListener("contextmenu", showMenu, false)
window.addEventListener("click", hideMenu, false)
function showMenu()
{
var left = arguments[0].clientX
var top = arguments[0].clientY
menuBox = window.document.querySelector('.menu')
menuBox.style.left = left + 'px'
menuBox.style.top = top + 'px'
menuBox.style.display = 'block'
arguments[0].preventDefault()
menuDisplayed = true
}
function hideMenu()
{
if(menuDisplayed == true) {
menuBox.style.display = 'none'
}
}
</script>
</head>
<body>
</h2>Right click mouse to view Context Menu</h2>
<div class="menu">
<div class="menu-item">Google</div>
<div class="menu-item">Facebook</div>
<hr>
<div class="menu-item">MSN</div>
<div class="menu-item">Bing</div>
</div>
</body>
</html>
Output:-
CONCLUSION :-
In this practical I successfully applied and demonstrate
implementing Menus.
CODE
<html>
<head>
<title>Banner Advertisements</title>
</head>
<body bgcolor="#EEEEEE">
<a href="https://www.javatutsweb.com">
<img src="java-programming-ad.jpg"/>
</a>
</body>
</html>
Output:-
CODE
<html>
<head>
<title>Image SlideShow</title>
<script>
var images = ["01.jpg", "02.jpg", "03.jpg", "04.jpg", "05.jpg"]; var count = 0;
function previousImage()
{
if(count!=0)
count--;
var id = document.getElementById("imageId");
id.src = "images/" + images[count];
} function nextImage() {
if(count!=4)
count++;
var id = document.getElementById("imageId");
id.src = "images/" + images[count];
}
</script>
</head>
<body>
<center>
CONCLUSION :-
In this practical I successfully applied and demonstrate
implementing Slideshow and Banner.