JavaScript & HTML Code

 

Code-1 Write a Event driven JavaScript code to calculate length of accepted string.

 

<html>

<head>

<title>

Javascript code

</title>

<script language="javascript">

function cal()

{

var a=prompt("Enter length of string");

var b=a.length;

document.write("The Length of string is="+b);

 

}

</script>

</head>

<body>

<h4>Javascript program</h4>

<input type="submit" value="Calculate" onclick="cal()">

</body>

</html>

 

---------------------------------------------------------------------------------------------------------

 

Code-2 Write a Event driven JavaScript code to Area of rectangle.

<html>

<head>

<title>

Javascript code

</title>

<script language="javascript">

function cal()

{

var a=prompt("Enter Base");

var b=prompt("Enter Height");

var area=1/2*a*b;

document.write("The Area of tectangle is="+area);

 

}

</script>

</head>

<body>

<h4> Javascript program</h4>

<input type="submit" value="Calculate" onclick="cal()">

</body>

</html>

---------------------------------------------------------------------------------------------------------

Code-3 Write a Event driven JavaScript code to check  whether given number is odd or even.

<html>

<head>

<title>

Javascript code

</title>

<script language="javascript">

function odd()

{

var a=prompt("Enter Number");

if (a%2==0)

{

document.write("Given number is Even");

}

else

{

document.write("Given number is Odd");

}

 

}

</script>

</head>

<body>

<h4> Javascript program</h4>

<input type="submit" value="Calculate" onclick="odd()">

</body>

</html>

 

---------------------------------------------------------------------------------------------------------

Code-4 Write a Event driven JavaScript code to calculate factorial of given number.

<html>

<head>

<title>

Javascript code

</title>

<script language="javascript">

function fact()

{

var i,f=1;

var a=prompt("Enter Number");

for(i=a;i>=1;i--)

{

f=f*i;

}

 

document.write("The Factorial is="+f);

 

 

 

}

</script>

</head>

<body>

<h4> Javascript program</h4>

<input type="submit" value="Calculate" onclick="fact()">

</body>

</html>

---------------------------------------------------------------------------------------------------------

 

 Write a Event driven JavaScript code to calculate display Area of ellipse(Hint area=3.14*r1*r2)

<html>

<head>

<title>

Javascript code

</title>

<script language="javascript">

function elip()

{

var r1=prompt("Enter Redius1");

var r2=prompt("Enter Redius2");

var elip=3.14*r1*r2;

document.write("Area of ellipse is="+elip);

}

 

</script>

</head>

<body>

<h4>Javascript program</h4>

<input type="submit" value="Calculate" onclick="elip()">

</body>

</html>

 ---------------------------------------------------------------------

Write a Event driven JavaScript code to display perimeter of Trapezium (Hint Perimeter=a+b+c+d)

 

<html>

 

<head>

 

<title>

 

Javascript code

 

</title>

 

<script language="javascript">

 

function per()

 

{

 

var p1=parseInt(prompt("Enter First Perimeter"));

 

var p2=parseInt(prompt("Enter Second Perimeter"));

 

var p3=parseInt(prompt("Enter Third Perimeter"));

 

var p4=parseInt(prompt("Enter Fourth Perimeter"));

 

pr=p1+p2+p3+p4;

 

 

 

 

document.write("Perimeter of Trapezium="+pr);

 

 

 

}

 

</script>

 

</head>

 

<body>

 

<h4>Javascript program</h4>

 

<input type="submit" value="Calculate" onclick="per()">

 

</body>

 

</html>

-----------------------------------------------------------------------------------

Write html program to create an ordered list of 3 languages used for speaking and unordered list having 2 computer languages. 

 

<!doctype html>

<html>

<head>

    <title> Languages </title>

</head>

<body>

 <h2> Languages used for Speaking</h2>

 <OL>

   <LI> English </LI>

   <LI> Hindi </LI>

   <LI> Marathi </LI>

 </OL>

 <h2> Computer Languages</h2>

 <UL>

   <LI> Java </LI>

   <LI> Python </LI>

 </UL>

</body>

</html>

 

Write html program to display names of two friends in ordered list and also display their hobbies under their name in unordered list. 

<!doctype html>

<html>

<head>

    <title> Friends and their Hobbies </title>

</head>

<body>

 <h2> Friends and their Hobbies</h2>

 <OL>

   <LI> Vedika </LI>

   <UL>

      <LI> Singing </LI>

      <LI> Dance </LI>

   </UL>

   <LI> Riya </LI>

   <UL>

      <LI> Reading Books </LI>

      <LI> Travelling to Historical Places </LI>

   </UL> 

 </OL>

 

</body>

</html>

Write html program to create an unordered list having names of two students. Add ordered list of subjects they selected:

<!doctype html>

<html>

<head>

    <title> Students subjects</title>

</head>

<body>

 <h2> Student List with subjects</h2>

 <UL>

   <LI> Sanika</LI>

   <OL>

      <LI> IT</LI>

      <LI> Maths</LI>

   </OL>

   <LI> Sachin</LI>

   <OL>

      <LI> English </LI>

      <LI> PT </LI>

   </OL> 

 </UL>

 

</body>

</html>


 

 

No comments:

Post a Comment