Prompt Help

Discussion in 'JavaScript' started by soapgurl21, Feb 5, 2008.

  1. #1
    I need help with a prompt that says:
    "Specify the operation you want the machine to perform
    a Simple Math calculation
    b Simple Physics formulae
    c Quote of the Day"

    That part I have down but I want it so that when they enter "a" JavaScript uses compute_Math_op(), "b" compute_Physical_quantities, or "c" quote_of_the_day() function.

    Thus far I have
    <script type="text/javascript">
    var y = prompt("Specify the operation you want the machine to
    perform /n a Simple Math calculation /n b Simple Physics formulae /n c
    Quote of the Day","");
    switch(x){

    case ‘a’: compute_Math_op();
    break;
    case ‘b’: compute_Physical_quantities();
    break;
    case ‘c’: quote_of_the_day();
    break;
    }
    </script>
    Really appreciate any help.
    Thanks
     
    soapgurl21, Feb 5, 2008 IP
  2. nhl4000

    nhl4000 Well-Known Member

    Messages:
    479
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    110
    #2
    <script type="text/javascript">
    var y = prompt("Specify the operation you want the machine to
    perform /n a Simple Math calculation /n b Simple Physics formulae /n c
    Quote of the Day","");
    switch(y){
    case ‘a’:
    compute_Math_op();
    break;
    case ‘b’:
    compute_Physical_quantities();
    break;
    case ‘c’:
    quote_of_the_day();
    break;
    }
    </script>
    Code (markup):
    Isn't it suppose to be switch(y)?
     
    nhl4000, Feb 5, 2008 IP
  3. MMJ

    MMJ Guest

    Messages:
    460
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #3
    var y = prompt('Specify the operation you want the machine to perform:'
    	+'\n a Simple Math calculation'
    	+'\n b Simple Physics formulae'
    	+'\n c Quote of the Day', '');
    switch(y){
    	case 'a':
    		compute_Math_op();
    		break;
    	case 'b':
    		compute_Physical_quantities();
    		break;
    	case 'c':
    		quote_of_the_day();
    }
    PHP:
     
    MMJ, Feb 7, 2008 IP