anticipating a click event within a while loop - jquery/javascrip
<p>I'm working on a little dice game app with javascript/jquery and the part where I run into trouble is in the following while loop.  I want the user to click the button and then the body of the while loop should execute.  However, with the following code, the contents of the while loop execute without waiting for the user to click each time.  Is this the right way to approach what I'm trying to do?</p>

<pre><code>            while (dice.value != rollFirst &amp;&amp; dice.value != 7)
            {
                $("#roll").click(function()
                {
                    $("#roll").unbind('click');
                    dice.roll();
                });
</code></pre>

<p>update:  Based on the responses, maybe I wasn't totally clear in what I'm trying to do.  For every iteration of the while loop, I want to user to click the roll button and only then do I want to continue execution of the contents of the while loop.  In other words, I want the while loop to wait until the users clicks "roll" for each iteration.</p>

<p>As it is right now, the logic of the program works but it doesn't wait for the user to click the roll button.</p>
