Closed Thread Icon

Topic awaiting preservation: Boolean Problem2 Pages that link to <a href="https://ozoneasylum.com/backlink?for=8713" title="Pages that link to Topic awaiting preservation: Boolean Problem2" rel="nofollow" >Topic awaiting preservation: Boolean Problem2\

 
Author Thread
Hiroki
Paranoid (IV) Inmate

From: NZ
Insane since: Dec 2002

posted posted 06-11-2003 23:48

Hi, guys. How are you?
May I ask you something?
I am having a problem to code Boolean method.

My mission:

quote:
Write a program to enter two numbers. Ask for num2 to be bigger tahn num1. If num2 > num1 then print out the difference between the two numbers. If num1 > num2 then print out an error message and ask for the numbers to be entered again. The program is to continue looping untilthe numbers are entered in the correct order and when they are the difference must be printed out.



My Code:

code:
<html>
<head>
<script type="text/javascript">
function cal(){
var numOne=parseFloat(document.theForm.one.value);
var numTwo=parseFloat(document.theForm.two.vlaue);
Result=numOne-numTwo;

if(numOne>numTwo){
document.theForm.result.value=Result;
}else{
alert("Num 1 > Num2!!!");
}

}

</script>
</head>
<body>
<form name="theForm">
<p>Enter the Number 1:
<input type="text" name="one"></p>
<p>Enter the Number 2:
<input type="text" name="two">
</P>
<p>
<input type="button" value="Get the difference!" onClick="cal()">
<input type="reset" value="Reset">
</p>
<p>
The difference is:
<input type="text" name="result">
</p>
<p>Please Look! Number1 must be greater than Number 2!</p>
</form>
</body>
</html>



Funny thing is that when I enter whatever the number always alert box pops up. If num1>num2, the difference of those two number is supposed to be shown in the text box. Not alert box at all. I cannot see what is wrong. Would you see anything about it?
My uploaded file is here.
Please help!


Hiroki Kozai

HZR
Bipolar (III) Inmate

From: Cold Sweden
Insane since: Jul 2002

posted posted 06-12-2003 00:02

You misspelled

code:
var numTwo=parseFloat(document.theForm.two.[b]vlaue[/b]);



Hiroki
Paranoid (IV) Inmate

From: NZ
Insane since: Dec 2002

posted posted 06-12-2003 00:35

Hi, HZR.
I am really sorry to bother you......
Many thanks for your help.
C U soon.
Regards,

Hiroki Kozai

HZR
Bipolar (III) Inmate

From: Cold Sweden
Insane since: Jul 2002

posted posted 06-12-2003 12:16

No, you didn't bother me at all

« BackwardsOnwards »

Show Forum Drop Down Menu