Skip to main content
deckarduk
Inspiring
August 25, 2021
Answered

Testing for the user cancelling a dialog

  • August 25, 2021
  • 1 reply
  • 1149 views

Hi there, please can someone help me with a question about the user cancelling a dialog?

 

I have a js process that works ok.

What I'm having a problem with is the user cancelling a dialog.

 

var exitDialog = 0; 
while (exitDialog !=999)
    	{ 
    		var cRtn = app.response("How many checkboxes would you like (1-9) ?");
    	    	if (cRtn > 0 && cRtn < 10)
   	    	    	{
       		    	    	var exitDialog = 999;
    	    	    	}
    	    	else 
    	    	    	{
    	    		    	if (cRtn == null) {break;}
    		    			app.alert('Please enter a value from 1-9');
    		    	}
    	}
// the rest of the process happens here and that works ok.

I can run the code above and it works fine apart from if the user cancels the dialog.

If I run the code above in the debugger it works ok. When I load it as a custom menu item it still works ok until the user cancels.

What I'm trying to do is allow the user to cancel the operation by pressing the 'Cancel' button on the dialog.

 

Please can someone point me in the right direction?

 

Thank you 🙂

 

This topic has been closed for replies.
Correct answer try67

Move the check whether cRtn is null above the other conditions.

Also, move the alert command above the break command, as it will never be reached if it's after it.

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
August 25, 2021

Move the check whether cRtn is null above the other conditions.

Also, move the alert command above the break command, as it will never be reached if it's after it.

deckarduk
deckardukAuthor
Inspiring
August 25, 2021

Thanks for the speedy response 🙂

I'll re-jig things as per your post.