Solution:
Html File:
<html>
<head>
<script type="text/javascript">
function Addition()
{
var ob;
ob=new XMLHttpRequest();
var no1=document.getElementById("no1").value;
//var no2=document.getElementById("no2").value;
ob.open("GET","SLIP27-p2-q1..php?num1="+no1,false);
ob.send();
// ob.onreadystatechange=function()
// {
//if(ob.readyState==4 && ob.status==200)
document.getElementById("add").innerHTML=ob.responseText;
// }
}
</script>
</head>
<body>
Enter first no :<input type=text name=no1 id="no1"><br>
<!-- Enter second no :<input type=text name=no2 id="no2"><br>
--><input type=button name=submit value=add onClick="Addition()"><br>
<span id="add"></span>
<body>
</html>
PHP File:
<?php
$n1=$_GET['num1'];
//echo"error";
$m=1;
if(!empty($n1))
{
for($i=1;$i<=$n1;$i++)
{
$m=$i*$m;
}
}
echo "Factorial = $m";
?>
0 Comments