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 7 of 7
  1. #1
    New to the CF scene
    Join Date
    May 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question:how to display Alert when people asking you by using prompt?

    My problem is that when the PROMPT box asking you to input a number, then the program should display/alert the number of times that you just input. I know how to do it by using form but prompt. Please help me. Thanks a lot.
    Last edited by lala138; 11-06-2004 at 01:34 AM.

  • #2
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    That doesn't make any sense

  • #3
    New to the CF scene
    Join Date
    May 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Brandoe85
    That doesn't make any sense
    Yes, I think so too. But this is the homework that my friend asked me today. I took 2 hours to try, but still don get it. So I ask for help here.
    Is it really not make sense??

  • #4
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rather basic:

    Code:
    <script type="text/javascript">
      var number = prompt('Please choose a number','');
      var count = 1;
        if(!isNaN(number)){
          while(count<=number){ 
                alert('You have entered '+number+'\nThis is alert '+count+++' of '+number);
          }
        }       else{ alert('You did not choose a number!') }
    </script>
    .....Willy

  • #5
    New to the CF scene
    Join Date
    May 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Willy Duitt
    Rather basic:

    Code:
    <script type="text/javascript">
      var number = prompt('Please choose a number','');
      var count = 1;
        if(!isNaN(number)){
          while(count<=number){ 
                alert('You have entered '+number+'\nThis is alert '+count+++' of '+number);
          }
        }       else{ alert('You did not choose a number!') }
    </script>
    .....Willy
    Wow.... You are excellent man. It works very fine. BTW, can you teach me how to display the number on the main page,(not Alert). Like the prompt ask you : prompt("choose a number!"); such as number 5 . Then if i want to display the "ouch!" 5 times on the main page. How to do that ? Thank you so much !

  • #6
    Smokes a Lot
    Join Date
    Jul 2003
    Location
    CA, USA
    Posts
    1,594
    Thanks
    5
    Thanked 20 Times in 20 Posts
    This sounds like homework, is this homework? If so, post what you have and we can help. Can't just do though.

    Edit: oh, already said it's homework, at least it's someone elses though. Better tell you what's going on to make sure you learn .


    Code:
    <script type="text/javascript">
      var number = prompt('Please choose a number',''); //your prompt
      var count = 1; //How many times has it gone
      var str="Ouch!"; //what word we are writing
        if(!isNaN(number)){ //is the input a number? If it is go to the while loop else go to the alert at the end
          document.write('You have entered '+number+'<br />'); //Tell the user what number they chose
          while(count<=number){  //until count greater than the number the user entered. Write ouch and the number of ouches so far.  Increment count each pass. 
                document.write('This is Ouch '+count+++' of '+number+'<br />');
          }
        }       else{ alert('You did not choose a number!') }  //this alert will display if the input is not a number
    </script>
    Basscyst
    Last edited by Basscyst; 11-07-2004 at 12:07 AM.
    Helping to build a bigger box. - Adam Matthews

  • #7
    New to the CF scene
    Join Date
    May 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Basscyst
    This sounds like homework, is this homework? If so, post what you have and we can help. Can't just do though.

    Edit: oh, already said it's homework, at least it's someone elses though. Better tell you what's going on to make sure you learn .


    Code:
    <script type="text/javascript">
      var number = prompt('Please choose a number',''); //your prompt
      var count = 1; //How many times has it gone
      var str="Ouch!"; //what word we are writing
        if(!isNaN(number)){ //is the input a number? If it is go to the while loop else go to the alert at the end
          document.write('You have entered '+number+'<br />'); //Tell the user what number they chose
          while(count<=number){  //until count greater than the number the user entered. Write ouch and the number of ouches so far.  Increment count each pass. 
                document.write('This is Ouch '+count+++' of '+number+'<br />');
          }
        }       else{ alert('You did not choose a number!') }  //this alert will display if the input is not a number
    </script>
    Basscyst
    I finished this course already. But my friend asked me how to do it, however I don't know how to do it.

    Basscyst:

    Thank you so much. It works very well. Very good & useful forum. Thanks! Thanks! Gotta tell my friend. lol :
    Last edited by lala138; 11-07-2004 at 07:02 AM.


  •  

    Posting Permissions

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