...

View Full Version : JavaScript prompt meny



zk0
02-13-2007, 08:51 PM
I need some help with a javascript prompt meny:

This is the code I got:


while (true) {

var meny = prompt ("0. Exit" + '<br />' +"1. Fahrenheit to Celsius" + "<br />" + "2. Celsius to Fahrenheit" + "<br />" + "3. Guess Number", "");

if(meny == 0) {
alert("You will Exit");
break;
}

else if(meny == 1) {
alert("Fahrenheit to Celsius");
}

else if(meny == 2) {
alert("Celsius to Fahrenheit");
}

else if (meny == 3) {
alert( "Guess Number" );
}

else (meny > 3) {
var meny = prompt ("0. Exit" + '<br />' +"1. Fahrenheit to Celsius"+"<br />"+"2. Celsius to Fahrenheit"+"<br />"+"3. Guess Number", "");
}

I want it to work like this:

If the user types in "0" she should exit the meny.
If the user types in "1" a script would load that converts F to C.
Etc etc...

But at the moment the script doesnt work and I am completely lost. Advice and help is really needed!

Thanks!

zk0
02-14-2007, 10:45 AM
No one knows? :(

zk0
02-14-2007, 11:21 AM
It's funny. Whenever I have posted help for something like this I somehow understand what I have done wrong...

Now it's working!


var meny = prompt ("0. Exit.\n\n1. Fahrenheit to Celsius.\n2. Celsius to Fahrenheit.\n3. Guess Number", "");

while (true) {

if(meny == 0) {
alert("You will Exit");
break;
}

else if(meny == 1) {
alert("Fahrenheit to Celsius");
var meny = prompt ("0. Exit.\n\n1. Fahrenheit to Celsius.\n2. Celsius to Fahrenheit.\n3. Guess Number", "");
}

else if(meny == 2) {
alert("Celsius to Fahrenheit");
var meny = prompt ("0. Exit.\n\n1. Fahrenheit to Celsius.\n2. Celsius to Fahrenheit.\n3. Guess Number", "");
}

else if (meny == 3) {
alert( "Guess Number" );
var meny = prompt ("0. Exit.\n\n1. Fahrenheit to Celsius.\n2. Celsius to Fahrenheit.\n3. Guess Number", "");
}

else if (meny > 3) {
var meny = prompt ("0. Exit.\n\n1. Fahrenheit to Celsius.\n2. Celsius to Fahrenheit.\n3. Guess Number", "");
}
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum