Closed Thread Icon

Topic awaiting preservation: Hmm...Please help! (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=8667" title="Pages that link to Topic awaiting preservation: Hmm...Please help! (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Hmm...Please help! <span class="small">(Page 1 of 1)</span>\

 
Hiroki
Paranoid (IV) Inmate

From: NZ
Insane since: Dec 2002

posted posted 05-22-2003 04:12

Hi, guys. How are you?
Well, I have been under a lot of problems, I am afraid.
Especailly today....

My mission:

quote:
It returns the suare and the square root of an entered number. The number should be between -100 and 100. Othersise alert box says whether the number is too high or too low.



code:
<html>
<head>
<script type="text/javascript">
function cal()
{
if(-100<theForm.num.value<100)
{
theForm.sq.value=theForm.num.value*theForm.num.value
theForm.root.value = Math.round(Math.sqrt(theForm.num.value)*100)/100;
}
else if(theForm.num.value>=100)
{
alert("Your number is too big!!!")
}
else
{
alert("Your number is too small!!!")
}

}

</script>
</head>

<body >

<form name="theForm">
<p>
X=
<input type="text" name="num" size="10">

<input type="button" value="Calculate" onClick="cal()">
<input type="reset" value="Reset">
</p>

<p>
X<sup>2<sup>=
<input type="text" name="sq">
</p>

<p>
Root X=
<input type="text" name="root">
</p>

</form>
</body>
</html>



Problem is alert box never pops up when I put in invalid number....
Would you see why???
Many thanks for sharing your time. Happy Thrusday.
Cya.

Hiroki Kozai

[This message has been edited by Hiroki (edited 05-22-2003).]

[This message has been edited by Hiroki (edited 05-22-2003).]

lallous
Paranoid (IV) Inmate

From: Lebanon
Insane since: May 2001

posted posted 05-22-2003 07:40
code:
if(-100<theForm.num.value<100)


change this to:

code:
x = parseInt(theForm.num.value);
if ( (x >= -100) && (x <= 100))
{
alert('yeah');
}
else
{
alert('number not between -100 and 100');
}



Elias

Hiroki
Paranoid (IV) Inmate

From: NZ
Insane since: Dec 2002

posted posted 05-22-2003 23:06

Hi, lallous! Good morning. How are you today???
Many many thank you for your help!!!!
It worked!

What I did is below:

code:
if((-100<theForm.num.value) && (theForm.num.value<100))



Instead of:

code:
if(-100<theForm.num.value<100)



It worked perfectly!

But can I ask something??? Do you have any idea why I cannot do like my way???
Many thanks in advance!! ( ^^ ) /

Hiroki Kozai

lallous
Paranoid (IV) Inmate

From: Lebanon
Insane since: May 2001

posted posted 05-23-2003 13:52

Hello Hiroki,

I am fine, hope you're doing fine too.


You cannot do -100<x<100 comparison in Javascript or any other high-level language I seen so far...
Because that is an invalid syntax.

To know what syntax is correct and what is not, you would better refer to a JavaScript manual/book

Elias

Hiroki
Paranoid (IV) Inmate

From: NZ
Insane since: Dec 2002

posted posted 05-26-2003 23:44

Hi,mate. Many many thanks for your explanation.
How are you today?
Are you living in Lebanon???!
Wow, it is far from here.
Glad to hear from you, mate.
Have a happy day.
Cya.

Hiroki Kozai

lallous
Paranoid (IV) Inmate

From: Lebanon
Insane since: May 2001

posted posted 05-28-2003 09:33

Yes, I live there...

It is a beautiful country...
Its system is hard to be understood by people that come from other civilized countries...

Happy day too.

Elias

« BackwardsOnwards »

Show Forum Drop Down Menu