Client Side Scripting (CSS) (22519) Semester - V (CO) : A Laboratory Manual For
Client Side Scripting (CSS) (22519) Semester - V (CO) : A Laboratory Manual For
for
(22519)
Semester – V
(CO)
Maharashtra state
Certificate
This is to certify that Mr. / Ms …Esha C. Rangari….……………
Roll No... ……65………......of Fifth Semester of Diploma in
………… Computer Science & Engineering..…………………….
of Institute…Government Polytechnic Gondia………..…………..
(Code ..... 22519..............) has attained predefined practical
outcomes (PROs) satisfactorily in course Client side scripting (22519)
for the academic year 20...20.to 20.-21..as prescribed in the
curriculum.
Resource Used :
Theory :
What is HTML?
What is Javascript?
<script ...>
JavaScript code
</script>
▪ Language
▪ Type
Explanation:
Arithmetic Operators:
Program Code :
<html>
<head>
<center>
<br><br>
c = a + b;
document.write(" <h3> Addition : " +c+ "<br><br>");
c = a - b;
document.write(" <h3> Substraction : " +c+ "<br><br>");
c = a * b;
document.write(" <h3> Multiplication : " +c+ "<br><br>");
c = a / b;
document.write(" <h3> Division : " +c+ "<br><br>");
c = a % b;
document.write(" <h3> Moduls : " +c+ "<br><br>");
</script>
</center>
</head>>
</html>
Output :
Conclusion:
We understand that how to write javascript with HTML for arithmetic expression
evaluation and message printing.
Resource Used :
Theory :
Decision Making:
Decision making structures require that the programmer specifies one or more
conditions to be evaluated or tested by the program, along with a statement or
statements to be executed if the condition is determined to be true, and optionally,
other statements to be executed if the condition is determined to be false.
The if...else if... statement is an advanced form of if…else that allows JavaScript to
make a correct decision out of several conditions.
Syntax:
if (expression 1){
} else if (expression 2) {
} else if (expression 3) {
} else {
Program Code :
<html>
<body>
<center>
<br><br>
<script>
else
</script>
</center>
</body>
</html>
Output :
Conclusion:
We understand that how to use decision-making & looping statements in JavaScript.
Resource Used :
Theory :
JavaScript Arrays
▪ An array is a special variable, which can hold more than one value at a time.
Declaring an array
1. By array literal
2. By using an Array constructor (using new keyword) : You can also create an array using
Array constructor with new keyword
1) var keyword
2) Array name
3) Assignment operator
4) new operator
5) Array ( ) constructor
Program Code :
<html>
<body>
<center>
<br><br>
<script type="text/javascript">
{
sum += arr[i];
product *= arr[i];
</script>
</center>
</body>
</html>
Output :
Conclusion:
We understand that how to implement arrays in JavaScript.
Resource Used :
Theory :
What is Function?
Declaring A Function:
Before we use a function, we need to define it. The most common way to define a
function in JavaScript is by using the function keyword, followed by a unique
function name, a list of parameters (that might be empty), and a statement block
surrounded by curly braces.
Syntax:
function functionname(parameter-list)
statements
Program Code :
<html>
<head>
<center>
<h1>CSS : Practical No 4</h1>
<h2>Develop a JS Program to implement Functions</h2>
<br><br>
<script>
function factorial(num)
{
var fact = 1;
for(i=1;i<=num;i++)
{
fact = fact * i ;
}
alert("Factorial of Number "+num+" is : " +fact);
}
</script>
</center>
</head>
<body>
<center>
<button onclick="factorial(6)"> Factorial of 6 </button>
</center>
</body>
</html>
Output :
Conclusion:
We understand that how implement functions JavaScript.
Resource Used :
Theory :
JavaScript Strings
▪ JavaScript Strings are used for storing and manipulating text.
▪ Strings in JavaScript can be enclosed within either “single quotes”, “double
quotes” or “backticks”:
var single_quoted = 'Single quoted string';
var double_quoted = "double-quoted string";
var backticks = `backticks string`;
String length
▪ The length property has the string length.
▪ Note that str.length is a numeric property, not a function. There is no need to
add parenthesis after it.
String Methods
3. str.indexOf(substr, [pos]) : Returns the index of (the position of) the first
4. str.concat(string) : Joins two or more strings. This method can be used instead of
Program Code :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initialscale=1.0">
<title>Practical No. 05</title>
</head>
<body>
<center>
<h1>CSS : Practical No 5</h1>
<h2>Develop Javascript To Implement Strings</h2>
<br><br>
<h3 id="fname">Sample String : Esha</h3>
<script>
var name =
document.getElementById("fname").textContent.slice(16);
function toUpperCaseString(){
document.getElementById("result").textContent =
"Uppercase : " + name.toUpperCase();
}
function toLowerCaseString(){
document.getElementById("result").textContent =
"Lowercase : " + name.toLowerCase();
}
function concatNewString()
{
document.getElementById("result").textContent =
"Concatenation : " + "Hello, ".concat(name);
}
function stringLength()
{
document.getElementById("result").textContent =
"Length : " + name.length;
}
function indexOfCharacters(){
var index = 0;
var result = "";
for(index; index < name.length; index++){
result = result + (name[index] + " = " +
name.indexOf(name[index], index) + ", ");
}
document.getElementById("result").textContent =
"Index Of : " + result;
}
</script>
<button onclick="toUpperCaseString()">Uppercase All</button>
<button onclick="toLowerCaseString()">Lowercase All</button>
<button onclick="concatNewString()">Prefix Hello</button>
<button onclick="stringLength()">String Length</button>
<button onclick="indexOfCharacters()">Index of All
Characters</button>
<br><br>
<h2 id="result"></h2>
</center>
</body>
</html>
Output :
Conclusion:
We understand that how implement Strings JavaScript.
Resource Used :
Theory :
▪ Form is typical layout on the web page by which a user can interact with the web
page.
▪ Typical components of forms are text, text area, checkboxes, radio buttons & push
buttons. These components of form are also called as form controls.
▪ HTML allows us to place these form components on the web page. All these form
contents in the <form> tag.
▪ The form has an attributes action which gets executed user clicks a button on the
form.
Uses of form:
1. Forms are used to collect the information from customer for online registration.
2. Forms are used for online survey.
3. Forms are used for conduction online examination.
4. The information present in the forms is submitted to the server for furtherprocessing.
Syntax:
</form>
1. Text:
2. Textarea:
• This is used when the user is required to give details that may be longer than a
single sentence.
• Multi-line input controls are created using HTML <textarea> tag.
3. Button:
Program Code :
<!DOCTYPE html>
<html>
<head>
<center>
<br><br>
<script type='text/JavaScript'>
function emailValidate()
var a = document.loginForm.user.value;
var h5 = document.getElementById("email");
h5.innerHTML = a;
if(a == "ishrangari@gmail.com")
return "ok";
else
function validate()
if(res == "ok")
console.log(pass);
if(pass == "ishrangari@123")
{
alert("Login Success");
else
alert("Login UnSuccess");
</script>
</center>
</head>
<body>
<fieldset>
</fieldset>
</form>
</body>
</html>
Output :
Conclusion:
We understand that how to create a webpage using form elements in JavaScript.
Resource Used :
Theory :
A form event is fired when a form control receive or loses focus or when the user
modify a form control value such as by typing text in a text input, select any option in
a select box etc. Here're some most important form events and their event handler.
The change event occurs when a user changes the value of a form element.
You can handle the change event with the onchange event handler.
Program Code :
<!DOCTYPE html>
<html>
<head>
<center>
<h1>CSS : Practical No 7</h1>
<h2>Create a webpage to implement Form Events : Part I</h2>
<br><br>
<script type='text/JavaScript'>
function highlight(ele)
{
ele.style.color = 'black';
ele.style.backgroundColor = 'cyan';
}
</script>
</center>
</head>
<body>
<form name="first">
<fieldset>
<legend> Login Details </legend>
Username: <input type="text" name="user" onchange="highlight(this)"/>
<br/><br/>
Password: <input type="password" name="pass"
onchange="highlight(this)"/>
<br/><br/>
<input type="submit" />
</fieldset>
</form>
</body>
</html>
Output :
Conclusion:
We understand that how to create a webpage using form events.
Resource Used :
Program Code :
<!DOCTYPE html>
<html>
<head>
<center>
<br><br>
<script type='text/JavaScript'>
function updateList(ele)
{
with(document.forms.myform)
if(ele == 1)
list[0].text = "C";
list[0].value = 1;
list[1].text = "Python";
list[1].value = 2;
list[2].text = "C++";
list[2].value = 3;
else
list[0].text = "Oracle";
list[0].value = 1;
list[1].text = "MySql";
list[1].value = 2;
list[2].text = "DB2";
list[2].value = 3;
</script>
</center>
</head>
<body>
<center>
<form name="myform">
<select name="list">
<option value=1>C++</optio>
</select>
onclick="updateList(this.value)">
Programming Languages
DataBases
</form>
</center>
</body>
</html>
Output :
Conclusion:
We understand that how to create a webpage using form events.
Resource Used :
Theory :
<!DOCTYPE html>
<html>
<head>
<style>
img{
width:90px;
height:40px;
</style>
</head>
<body>
<center>
<br><br>
<form name="f">
</form>
</center>
</body>
</html>
Output :
Conclusion:
We understand that how to develop webpage using Intrinsic Java Function in
JavaScript.
Resource Used :
Theory :
Cookies Basics
▪ A cookie is a small piece of information that a web site writes to user’s hard disk
when he visit the site.
▪ Cookies let you store user information in web pages.
▪ Cookies are data, stored in small text files, on your computer.
▪ When a web server has sent a web page to a browser, the connection is shut down,
and the server forgets everything about the user.
▪ Cookies were invented to solve the problem “how to remember information about the
user”:
▪ When a user visits a web page, his/her name can be stored in a cookie.
▪ Next time the user visits the page, the cookie “remembers” his/her name.
▪ A JavaScript can be used to create cookies whenever someone visits the web page that
contains the script.
▪ A JavaScript can also be used to read cookies stored on a user’s computer, and it uses
the information stored in a cookie to personalize the web page that a user visits.
▪ The text of a cookie must contain a name-value pair, which is a name and value of the
information.
▪ There are two types of Cookies:
o Session cookies
o Persistent cookies
1. Session Cookies
2. Persistent Cookies
Program Code :
<html>
<head>
<script>
function create()
document.cookie="username = "+cookies+";";
alert("Cookie Created"+document.cookie);
document.getElementById("user").value = "";
}
function read()
var x ;
if(document.cookie =="")
x="";
else
x=document.cookie;
alert(" "+x);
function del()
if(document.cookie !="")
d.setTime(d.getTime()-(1000*60*60*24))
alert("Cookie Delete");
else
</script>
</head>
<body>
<center>
<br><br>
</center>
</body>
</html>
Output :
Conclusion:
We understand that how to create a cookies.
Thank_You