Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    zk0
    zk0 is offline
    New Coder
    Join Date
    Dec 2006
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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!

  • #2
    zk0
    zk0 is offline
    New Coder
    Join Date
    Dec 2006
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No one knows?

  • #3
    zk0
    zk0 is offline
    New Coder
    Join Date
    Dec 2006
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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", "");
    		}
        }


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •