...

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



lala138
11-06-2004, 12:31 AM
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.

Brandoe85
11-06-2004, 01:22 AM
That doesn't make any sense:confused:

lala138
11-06-2004, 02:10 AM
That doesn't make any sense:confused:
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. :D
Is it really not make sense?? :confused: :confused: :confused:

Willy Duitt
11-06-2004, 03:04 AM
Rather basic:



<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

lala138
11-06-2004, 05:50 AM
Rather basic:



<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.... :eek: :eek: 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 ! :p :p

Basscyst
11-06-2004, 10:24 PM
This sounds like homework, is this homework? If so, post what you have and we can help. Can't just do though.

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



<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

lala138
11-07-2004, 05:30 AM
This sounds like homework, is this homework? If so, post what you have and we can help. Can't just do though.

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



<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. :confused: :confused:

Basscyst:

Thank you so much. It works very well. Very good & useful forum. Thanks! Thanks! Gotta tell my friend. lol :



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum