www.webdeveloper.com
Results 1 to 2 of 2

Thread: Quick prompt method question

  1. #1
    Join Date
    Mar 2011
    Posts
    4

    Quick prompt method question

    In order to save a little space I would like to change the three current prompt methods into only one, getting all three numbers together.

    Code:
    var a = prompt("What is the first value? \n", " ");
    var b = prompt("What is the second value? \n", " ");
    var c = prompt("What is the third value? \n", " ");

  2. #2
    Join Date
    Mar 2007
    Location
    U.K.
    Posts
    1,127
    Code:
    var vals;
    
    while( ( vals = prompt( "Enter the first, second and third values separated by spaces", " ").replace( /^\s*|\s*$/g, '').split( /\s+/ ) ).length != 3 )
    ;
    
    alert( vals );

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles