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 11-06-2004, 12:31 AM   PM User | #1
lala138
New to the CF scene

 
Join Date: May 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
lala138 is an unknown quantity at this point
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 12:34 AM..
lala138 is offline   Reply With Quote
Old 11-06-2004, 01:22 AM   PM User | #2
Brandoe85
teh Moderatorinator


 
Join Date: Sep 2004
Location: USA
Posts: 2,472
Thanks: 4
Thanked 40 Times in 40 Posts
Brandoe85 will become famous soon enough
That doesn't make any sense
__________________
-Brando
Why using tables for eating is stupid!
Brandoe85 is offline   Reply With Quote
Old 11-06-2004, 02:10 AM   PM User | #3
lala138
New to the CF scene

 
Join Date: May 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
lala138 is an unknown quantity at this point
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??
lala138 is offline   Reply With Quote
Old 11-06-2004, 03:04 AM   PM User | #4
Willy Duitt
Banned

 
Join Date: Sep 2003
Posts: 3,620
Thanks: 0
Thanked 0 Times in 0 Posts
Willy Duitt is an unknown quantity at this point
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
Willy Duitt is offline   Reply With Quote
Old 11-06-2004, 05:50 AM   PM User | #5
lala138
New to the CF scene

 
Join Date: May 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
lala138 is an unknown quantity at this point
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 !
lala138 is offline   Reply With Quote
Old 11-06-2004, 10:24 PM   PM User | #6
Basscyst
Smokes a Lot


 
Join Date: Jul 2003
Location: CA, USA
Posts: 1,594
Thanks: 5
Thanked 20 Times in 20 Posts
Basscyst is on a distinguished road
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
__________________
Helping to build a bigger box. - Adam Matthews

Last edited by Basscyst; 11-06-2004 at 11:07 PM..
Basscyst is offline   Reply With Quote
Old 11-07-2004, 05:30 AM   PM User | #7
lala138
New to the CF scene

 
Join Date: May 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
lala138 is an unknown quantity at this point
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 06:02 AM..
lala138 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 01:02 AM.


Advertisement
Log in to turn off these ads.