in Education by
Ok, I'm doing a bunch of RIA/AJAX stuff and need to create a "pretty", custom confirm box which is a DIV (not the built-in javascript confirm). I'm having trouble determining how to accomplish a pause in execution to give the user a chance to accept or decline the condition before either resuming or halting execution. (depending upon their answer) So here's the general flow of logic I'm dealing with: User selects an item from dropdown and clicks button. In client-side javascript eventhandler for button, I need to check a (this is the key) SERIES of conditions for the item they chose in dropdown. These conditions could possibly result in not showing any confirmation at all or possibly only some of the conditions may evaluate to true which means I'll need to ask the user to accept or decline the condition before proceeding. Only one confirmation should be show at a time. To demonstrate the logic: function buttonEventHandler() { if (condition1) { if(!showConfirmForCondition1) // want execution to pause while waiting for user response. return; // discontinue execution } if (condition2) { if (!showConfirmForCondition2) // want execution to pause while waiting for user response. return; // discontinue execution } if (condition3) { if (!showConfirmForCondition3) // want execution to pause while waiting for user response. return; // discontinue execution } ... } If anybody has dealt with this challenge before and found a solution, help would be greatly appreciated. As a note, I'm also using the MS Ajax and jQuery libraries although I haven't found any functionality that may already be included in those for this problem. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
I'm afraid to say that it's not possible to pause the Javascript runtime in the same way that the "confirm" and "alert" dialogs pause it. To do it with a DIV you're going to have to break up your code into multiple chunks and have the event handler on the custom confirm box call the next section of code. There have been some projects to bring "continuations" support into Javascript, such as Narrative Javascript so if you're really keen on getting it to work in a single block of code you could look into that.

Related questions

0 votes
    Ok, I'm doing a bunch of RIA/AJAX stuff and need to create a "pretty", custom confirm box which ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 10, 2022 in Education by JackTerrance
0 votes
    _______ means that data used during the execution of a transaction cannot be used by a second transaction ... Database Interview Questions and Answers for Freshers and Experience...
asked Oct 11, 2021 in Education by JackTerrance
0 votes
    _______ means that data used during the execution of a transaction cannot be used by a second transaction ... Schemes topic in section Concurrency Control of Database Management...
asked Oct 10, 2021 in Education by JackTerrance
0 votes
    How can I ask the user to enter a value during the execution of a GnuPlot script? I would like ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 17, 2022 in Education by JackTerrance
0 votes
    Given my animation scene1. How can I pause it using a button named “Skip” using C# code behind, and play another animation scene2 after....
asked Dec 31, 2021 in Education by JackTerrance
0 votes
    i have a control that is organized like this and i want to have the javascript registered on the calling ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 12, 2022 in Education by JackTerrance
0 votes
    i have a control that is organized like this and i want to have the javascript registered on the calling ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 12, 2022 in Education by JackTerrance
0 votes
    I trying use Dungeons example in my app. In Android development guide it's written that I should confirm ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 20, 2022 in Education by JackTerrance
0 votes
    I trying use Dungeons example in my app. In Android development guide it's written that I should confirm ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    I want to show a confirmation box from c# code rather than JavaScript. Is there any way I can ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    a) Harshita wants to create an HTML form. Which tag should she use to create this form? Her teacher has asked ... plz answer this fast Select the correct answer from above options...
asked Dec 14, 2021 in Education by JackTerrance
0 votes
    Default Environment Variables by Jenkins & How to introduce custom environment variables?...
asked Sep 14, 2021 in Technology by JackTerrance
0 votes
    What are default Environment Variables by Jenkins & How to introduce custom environment variables?...
asked Jul 17, 2021 in Technology by JackTerrance
0 votes
    What is the method used to pause data events? (a) s.pause(); (b) s.stop(); (c) s. ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 23, 2021 in Education by JackTerrance
...