Click to See Complete Forum and Search --> : User inputs two numbers and are displayed in assending order


tane
04-19-2004, 01:19 AM
having problems with this script i am trying to write a script that will allow the user to input 2 numbers and have the script dispaly them on the page in assending order
here is what i have done but i keep getting a error message around where the else statement is......


var numb1=prompt("please enter your first number","");
var numb2=prompt("please enter your second number","");
if
(numb1<numb2);
document.writeln(numb1,numb2);

else
{ document.writeln(numb2,numb1);
}

Pittimann
04-19-2004, 01:30 AM
Hi!

Try removing the red semi colon:

if
(numb1<numb2);
document.writeln(numb1,numb2);
else
{ document.writeln(numb2,numb1);
}

Another thing is: prompts will deliver string values and not numeric ones. To get correct results, you should transform them into numeric values...

Cheers - Pit

tane
04-19-2004, 01:33 AM
thanks mate!! works now!! cheers

Pittimann
04-19-2004, 01:38 AM
Hi!

You're welcome! :)

Cheers - Pit