<html>
<head>
</head>
<body>
<input type="text" name="txt1" id="txt1" >
<input type="button" value="Submit" onclick="function1()"><br />
<input type="text" name="txt2" id="txt2">
<script type="text/javascript">
var randomNum = parseInt(100 * Math.random());
var num = parseInt(document.getElementById("txt1").innerHTML);
function function1() {
while (randomNum != num) {
if (randomNum < num) {
document.txt2.innerHTML.write("Your Value Is Too Big");
}
if (randomNum > num) {
document.txt2.innerHTML.write("Your Value Is Too Small");
}
if (num==randomNum) {
document.txt2.innerHTML.write("You Are Correct");
}
}
}
</script>
</body>
</html>
Last edited by Benjamin on Thu Oct 07, 2010 5:40 am, edited 1 time in total.
Reason:Added [syntax=html] tags.
<html>
<head>
</head>
<body>
<input type="text" name="txt1" id="txt1" onchange="">
<input type="button" value="Submit" onclick="function1()"><br />
<input type="text" name="txt2" id="txt2">
<script type="text/javascript">
var randomNum = parseInt(100 * Math.random());
var num = parseInt(document.getElementById("txt1").value);
var txt2 = document.getElementById("txt2").innerHTML
function function1() {
while (randomNum != num) {
if (randomNum < num) {
document.txt2.innerHTML.write("Your Value Is Too Big");
}
if (randomNum > num) {
document.txt2.innerHTML.write("Your Value Is Too Small");
}
if (num==randomNum) {
document.txt2.innerHTML.write("You Are Correct");
}
}
}
</script>
</body>
</html>
Last edited by Benjamin on Thu Oct 07, 2010 8:03 am, edited 1 time in total.
Reason:Added [syntax=html] tags.
i still receive a error. after i changed the script.
<html>
<head>
</head>
<body>
<input type="text" name="txt1" id="txt1" onchange="">
<input type="button" value="Submit" onclick="function1()"><br />
<input type="text" name="txt2" id="txt2">
<script type="text/javascript">
var randomNum = parseInt(100 * Math.random());
var num = parseInt(document.getElementById("txt1").value);
var txt2 = document.getElementById("txt2").innerHTML
function function1() {
while (randomNum.value != num.value) {
if (num.value < randomNum.value) {
document.txt2.innerHTML.write("Your Value Is Too Big");
}
if (randomNum > num) {
document.txt2.innerHTML.write("Your Value Is Too Small");
}
if (num==randomNum) {
document.txt2.innerHTML.write("You Are Correct");
}
}
}
</script>
</body>
</html>