Slip 21 - A) Write a java script code to accept the values of x and y and then display xy

Solution:

<HTML><body>
<script>
function find()
{
var power=1;
var no1=parseInt(frm.txt1.value);
var no2=parseInt(frm.txt1.value);
while (no2>0)
{
power = power*no1;
--no2;
document.getElementById("answer").value= power;
}
}
</script>
<form name="frm">
Enter a 1st Number:<input name="txt1" type="text" /><br><br>
Enter a 2nd Number:<input name="txt2" type="text" /><br>
<input name="b1" onclick="find();" type="button" value="display" /></form><br>
<label> Volume: </label><input type="text" id="answer" size="30"/><br>
</BODY>
</HTML>

Post a Comment

0 Comments