Wednesday, February 4, 2015

Subtract Random Number

<html>
<head><title>Substact Random Numbers</title>

<script>
score=0;

function mySum(a,b)/>
{
sum= a - b;
 ans= parseInt(document.forms.myForm);

 if (ans == sum)
{

alert("Great JOB!");
score++;

}
else

alert("Try again! (T.T)");

if (score == 5)
alert("You Already answered 5"+ "\n" + "questions!! thanks for answering")





}

</script>





</head>

<body>
<Form Name="myForm">
<script language="javascript">
var a=parseInt(1+ Math.random()*5);
var b=parseInt(1+ Math.random()*5);
if(a<b)
{
var temp=a;
a=b;
b=temp;
}
document.write (" " + a  + "<br/>");
document.write (" - " + "<br/>");
document.write (" " + b + "<br/>");
document.write ("____" + "<br/>");
</script>
<input type="text" name="output" ><br/>
<input type="submit" name="check" value="Check Answer!!" onclick='mySum(a,b)/>';>

</form>


</body>



</html>



No comments:

Post a Comment

Dharamart.blogspot.in