How would I make a confirm box at the end of my script, to keep looping all the code before it when the user clicks on "OK", and to completly end my script when the user clicks on "Cancel"?
Thanks, any help appreciated.
Three answers:
Dave P
2012-11-28 17:44:36 UTC
The simplest way is to put all your code that you want to be controlled by the user, inside a function with a name:
function keepLooping()
{
// code here;
}
Then have your message box and use the return to call or ignore the function (put code in the script but outside of the function above):
if (confirm("press ok to run or cancel to end")==true)
{
keepLooping();
}
?
2016-11-03 08:22:09 UTC
sure, you could replace forms of Christianity, yet it extremely is not any more a range to be taken gently. you could want to take confirmation education in Catholicism beforehand you agree on even with if or now no longer you need be shown Catholic. If after all the preparation, you agree on Catholicism extremely isn't for you, then you actually would want to take confirmation education interior the Lutheran Church and see if it extremely is precise. If now no longer, then you actually would want to take catechism education with the Methodists (i do now no longer imagine all forms of Methodists make particular, yet even as the church you %.. does no longer, they a minimum of ought to wish to have catechism courses).
green meklar
2012-11-30 11:07:51 UTC
You want something like this:
function whatever()
{
while(true)
{
dostuff();
if(confirm("Do you want to end the script now?"))
{
return;
}
}
}
ⓘ
This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.