Aprajita WT Exp 6 To 9

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

DEPARTMENT OF INFORMATION TECHNOLOGY

PRACTICAL NO. 7

Title: Write a program in which when page loads it will ask you for entering number & it will display the

table of that number in table

Objective: To check whether you enter the number at the loading of the page.

S/W Requirement: Web Browser (Internet Explorer, Mozilla )

H/W Requirement: Intel P-IV, 256 MB Ram.

CODE:-
<html>
<head>
<title>Table in Java Script</title>
<script language="javascript">

var i;

i=prompt("Enter a value", 10);


document.write("<table width='200' border='1'>")

for (k=1;k<=10;k++

{ document.write("<tr><td>");

document.write(i + "*" + k);

document.write("</td><td>");

document.write(i * k);

document.write("</td></tr>");
}

document.write("</table>")

</script>

</head>

Deepanshu 2002833
DEPARTMENT OF INFORMATION TECHNOLOGY

<body>
</body>
</html>

Output-:

Deepanshu 2002833
DEPARTMENT OF INFORMATION TECHNOLOGY

PRACTICAL NO. 8

Title: Write a script that evolutes the factorials of integers from 1 to 10 display the result in HTML table

format.

Objective: To find factorial of numbers and display output in table format.

S/W Requirement: Web Browser (Internet Explorer, Mozilla )

H/W Requirement: Intel P-IV, 256 MB Ram.

CODE:-

<html>
<head><title>Factorial in Java Script</title>
<script language="javascript">

function fact(k)
{
if (k==1)
{
return 1;
}
else
return k*fact(k-1);
}
var i;

document.write("<table width='250' border='1'>")


document.write("<tr><td colspan='2'>FACTORIAL OF FIRST 10 Numbers</td></tr>");
for (k=1;k<=10;k++)

Deepanshu 2002833
DEPARTMENT OF INFORMATION TECHNOLOGY

document.write("<tr><td>");
document.write("Factorial of " + k);
document.write("</td><td>");
document.write(fact(k));
document.write("</td></tr>");
}

document.write("</table>")

</script>

</head>
<body>
</body>
</html>

Output-:

Deepanshu 2002833
DEPARTMENT OF INFORMATION TECHNOLOGY

Deepanshu 2002833
DEPARTMENT OF INFORMATION TECHNOLOGY

PRACTICAL NO. 9

Title: Write a Program to swap two images in JavaScript

Objective: Swap the two images to change one image to another using mouse pointer that helps in event
driven programming.

S/W Requirement: Web Browser (Internet Explorer, Mozilla), Notepad.

H/W Requirement: Intel P-IV, 256 MB Ram.

CODE:-

<html>
<head><title>swapping of two images</title>

<script language="javascript">
function swapimages(a,b)
{ var v1=document.images[a].src;
document.images[a].src=document.images[b].src;
document.images[b].src=v1;
}
</script>
</head>
<body><div align=center>
<img src="F:\pictures\Chateau.jpg" height=250 width=250>
<img src="F:\pictures\Paradise.jpg" height=250 width=250><p>
<form>
<input type="button" value="swap the two images" onclick="swapimages(0,1)">

</form>

Deepanshu 2002833
DEPARTMENT OF INFORMATION TECHNOLOGY

</div>
</body>
</html>

Output:

Deepanshu 2002833

You might also like