By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,417 Members | 1,845 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,417 IT Pros & Developers. It's quick & easy.

function blocking waiting for user interaction

P: n/a
hello.

I'm trying to halt a function's execution while waiting for user
interaction.

For example, I have a function called getUserValue() that pops up a hidden
div containing several buttons. Each button sets a value. I want use a
function to pop the box, wait for the users' button press, and then continue
the function based on what the user presses.

Behold, simi-code:

function getUserValue() {
... lots of code ...
var returnValue = doPopBox();
... lots more code based on users selection in doPopBox();
}

I've written quite a bit of supporting code, but the getUserValue()
continues to execute after the box is popped up, even before the user
presses a button.

I used setTimeout() to check to see if the button has been pressed -- but
when the timer starts, the interface is locked and a button cannot be
pressed. I also tried using a recursive function, (check value=null, if it
is, recheck), but Firefox and IE apparently don't like what may seem like an
unending recursive loop.

Is anyone doing this already in code? Any suggestions?

Thanks!

JMcdugal
Oct 26 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
ext237 wrote:
I'm trying to halt a function's execution while waiting for user
interaction.
Sorry, not possible.
Instead, display what you need to, then when user interaction happens, act
on it.
For example, I have a function called getUserValue() that pops up a
hidden div containing several buttons. Each button sets a value. I
want use a function to pop the box, wait for the users' button press,
and then continue the function based on what the user presses.
Instead, just try to prevent the user from doing anything until they act on
the popup. Do this either using the browser's built-in modal dialog (if
supported) or a simulated modal dialog like:
http://www.javascripttoolbox.com/lib/popup/example.php

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Oct 26 '06 #2

P: n/a

"Matt Kruse" <ne********@mattkruse.comwrote in message
news:eh*********@news2.newsguy.com...
ext237 wrote:
>I'm trying to halt a function's execution while waiting for user
interaction.

Sorry, not possible.
Instead, display what you need to, then when user interaction happens, act
on it.
Yikes. Wanted to do a global find/replace on confirm boxes for our app.
Thanks for the reply.

JM
Oct 26 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.