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.
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??
<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>
<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 !
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
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 :