0% found this document useful (0 votes)
21 views20 pages

Vaataanaa No. 1

Uploaded by

jagtaptanay80
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views20 pages

Vaataanaa No. 1

Uploaded by

jagtaptanay80
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 20

Practical No.

// If-Else

<html>

<head>

<title>

Voter

</title>

<body>

<script>

age=20;

document.write("Voter age is 18");

document.write("<br>");

if(age>18)

document.write("Elgilbe to vote");

else

document.write("Not Eligible");

</script>

</body>

</head>

Ouput :
// For-Loop

<html>

<head>

<title>For Loop</title>

</head>

<body>

<script>

document.write("1 to 10 numbers as:");

document.write("<br>");

for (let i=0;i<=10;i++)

document.write(i);

document.write("<br>");

documen.write("Continue numbers");

</script>

</body>

</html>

Output :
// Switch Statement

<html>

<head>

<title>Switch Statement</title>

</head>

<body>

<script>

var ch="o";

switch(ch)

case 'a':document.write("A is a vowel");

break;

case 'e':document.write("E is a vowel");

break;

case 'i':document.write("I is a vowel");

break;

case 'o':document.write("O is a vowel");

break;

case 'u':document.write("U is a vowel");

break;

</script>

</body>

</html>

Ouput :
//Do while loop

<html>

<head>

<title>

Do whilel loop

</title>

</head>

<body>

<script>

var x=0;

do{

document.write("Value="+x+"<br>");

x++;

while(x<=20);

document.write("Loop Exists")

</script>

</body>

</html>

Output :
Practical No. 2
//Sort Element

<html>

<head>

<title>Switch Statement</title>

</head>

<body>

<script>

var ch="o";

switch(ch)

case 'a':document.write("A is a vowel");

break;

case 'e':document.write("E is a vowel");

break;

case 'i':document.write("I is a vowel");

break;

case 'o':document.write("O is a vowel");

break;

case 'u':document.write("U is a vowel");

break;

</script>

</body>

</html>

Ouput :
//Join and concat

<html>

<head>

<title>Join an array</title>

</head>

<body>

<script>

var arr=new Array();

arr[0]="One";

arr[1]="Two";

arr[2]="Three";

var s1=arr.join();

document.write("String="+s1+"<br>");

var s2=arr.join("-");

document.write("String Join="+s2+"<br>");

var s2=new Array();

arr2[0]="Four";

arr2[1]="Five";

arr2[2]="Six";

var s3=arr.concat(arr2);

document.write("String Concat="+s3+"<br>");

</script>

</body>

</html>

Output :
// add Element

<html>

<head>

<title>Add an array</title>

</head>

<body>

<script>

var items=new Array(4);

items[0]="One";

items[1]="Two";

items[2]="Three";

items[3]="Four";

items.push("Five");

items.unshift("Zero");

items.shift();

items.pop();

for(i=0;i<items.length;i++)

document.write(items[i]+" ");

</script>

</body>

</html>

Output :
Practical No.3
//calling with argument

<!DOCTYPE html>

<html>

<head>

<script type="text/javascript">

function func(a)

document.write("This the function with argument containing variable a as" + a);

</script>

</head>

<body>

<h4>Function with argument</h4>

<script type="text/javascript">

func(10);

</script>

</body>

</html>

Output :
<!DOCTYPE html>

<html>

<head>

<script type="text/javascript">

function func()

return "Tanay";

</script>

</head>

<body>

<script type="text/javascript">

document.write(func());

</script>

</body>

</html>

Output :
// Addtiton

<!DOCTYPE html>

<html>

<head>

<title>addition Function</title>

</head>

<body>

<script type="text/javascript">

var add = new Function("num1", "num2", "return num1+num2");

document.writeln(add(2,5));

</script>

</body>

</html>
Practical No.5
// Mouse Event

<head>

<title>House Events</title>

<script>

function react()

alert("Please enter any value");

</script>

</head>

<body>

<form name="myform" action="" method="post" onmousedown="react()">

<input value="CLICK MOUSE HERE">

</form>

</form>

</body>

</html>

Output :
// Mouse Related Event

<html>

<body>

<div id="panel"></div>

<script>

function clickResponse()

this.innerHTML+= "Click detected<hr>";

function doubleclickResponse()

this.innerHTML += "<br>Double-Click detected<br>";

function mousedownResponse()

this.innerHTML+="<br>Mouse button down<br>";

function mouseupResponse()

this.innerHTML+="<br>Mouse button up<br>";

function init()

var panel= document.getElementById("panel");

panel.innerHTML="Click Here &gt; <br>";

panel.onclick=clickResponse;

panel.ondblclick=doubleclickResponse;

panel.onmouseup= mouseupResponse;

panel.onmousedown= mousedownResponse;

document.addEventListener ("DOMContentLoaded", init, false); </script>

</body>

</html>
Ouput :
Practical No.4
// Registration Form

<html>

<head>

<title> FORM USING FORM ELEMENTS </title>

</head>

<body>

<h1> REGISTRATION FORM </h1>

<script>

function Click()

</script>

<form name "RegForm" onclick "Click">

<p>Name: <input type='text' size=65 name "Name"></p><br>

<p>Address: <input type='text' size=65 name "Address"></p><br>

<p>E-Mail Address:<input type='text' size= 65 name="E-Mail"></p><br>

<p>Password:<input type='text' size=65 name="Password"></p><br>

<p>Telephone:<input type='text' size= 65 name="Telephone"></p><br>

<p> SELECT YOUR COURSE

<select type="text" value="" name="Subject">

<option>C</option>

<option>C++</option>

<option>JAVA</option>

<option>ADV.JAVA</option>

<option>VB.NET</option>

</select>

/p> <br><br> <

<p> Comments <textarea cols="55" name="Comments"> </textarea></p>

<p> <input type="submit" value="Submit" name="Submit"> <input type="reset" value="Reset" name="Reset">

</form>

</p>

</form>

</body>

</html>
Output :
Practical No. 6
// Key Events

<html>

<head>

<title>Key Event</title>

</head>

<body>

<div id="panel"></div>

<script>

var panel;

panel=document.getElementById("panel");

panel.innerHTML="Press a key...";

document.addEventListener("keydown", keydown, false);

document.addEventListener("keyup", keyup, false);

document.addEventListener("keypress", keypress, false);

function keydown()

panel.innerHTML+="<br/>Key Pressed: ";

function keyup()

{ panel.innerHTML+= "<br/>Key Released";

function keypress(e)

var keynum = (window.event)?event.keyCode:e.which;

panel.innerHTML=String.fromCharCode(keynum);

</script>

</body>

</html>
Output :
Practical No. 7
//Intrinsic Function

<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 :
// Disabling the elements

<!DOCTYPE html>

<html>

<head>

<title>Disable Elements Example</title>

</head>

<body>

<input type="text" id="textInput" value="Type something here">

<button id="disableButton">Disable Elements</button>

<input type="checkbox" id="checkbox" checked> Check me

<script>

const textInput = document.getElementById('textInput');

const disableButton = document.getElementById('disableButton');

const checkbox = document.getElementById('checkbox');

disableButton.addEventListener('click', function() {

textInput.disabled = true;

checkbox.disabled = true;

disableButton.disabled = true;

disableButton.textContent = "Elements Disabled";

});

</script>

</body>

</html>
Output :

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy