Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-13-2007, 08:51 PM   PM User | #1
zk0
New Coder

 
Join Date: Dec 2006
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
zk0 is an unknown quantity at this point
JavaScript prompt meny

I need some help with a javascript prompt meny:

This is the code I got:

Code:
	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 is offline   Reply With Quote
Old 02-14-2007, 10:45 AM   PM User | #2
zk0
New Coder

 
Join Date: Dec 2006
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
zk0 is an unknown quantity at this point
No one knows?
zk0 is offline   Reply With Quote
Old 02-14-2007, 11:21 AM   PM User | #3
zk0
New Coder

 
Join Date: Dec 2006
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
zk0 is an unknown quantity at this point
It's funny. Whenever I have posted help for something like this I somehow understand what I have done wrong...

Now it's working!

Code:
	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", "");
		}
    }
zk0 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:10 PM.


Advertisement
Log in to turn off these ads.