get values from an href link and pass to jquery
<p>I am new to the world of jquery and trying to figure out how things should play out. I am trying to setup a link that will start a function that does two things. the fist being create a domwindow that has a form in it and the second get the values in the href link click on and assign them to the hidden inputs in the form.<br>
does anybody know how I would be able to get the values in the href as soon as I click on it? from the looks of it I have to click on it for the second time for it to extract the values. From what I gather, it looks like it has to update the url on the first click then When I click on the link the second time it gives me the values from the first link. (ie. first click would have from=1&amp;to=2 and second link would have from=3&amp;to=4) but on the first click it does not get any thing and reports as undefined, however on the second click instead of getting 3 and 4 it will get 1 and 2 because that it the value available for it in the url.
now I suspect there is no way for me to fix that bit if there is I sure would like to know it. if not I might have to resort to using a button which will give me the values with hidden inputs attached to it, not sure.... 
In any case here code and any help would be very much appreciated  </p>

<pre><code>&lt;?php   $from="0";  $to="10";
    for ($x=1; $x&lt;=4; $x++){$from++; $to++;?&gt;
    &lt;a href="#&amp;to=&lt;?php echo $to;?&gt;&amp;from=&lt;?php echo $from;?&gt;" class="foo"&gt;user&lt;?php echo $x;?&gt;&lt;/a&gt;&lt;br&gt;
&lt;?php } ?&gt;
       $('.foo').click(function(){
        $.openDOMWindow({
            windowSourceID:'#msgBox',
            height:135,
            width:300,
                overlay:1,
                positionType:'anchoredSingleWindow',
                windowBGColor:'#f9f5f5',
                anchoredSelector:'.foo',
            });
                    $.extend({
                      getUrlVars: function(){
                        var vars = [], hash;
                        var hashes = window.location.href.slice(window.location.href.indexOf('?') + 2).split('&amp;');
                        for(var i = 0; i &lt; hashes.length; i++)
                        {
                          hash = hashes[i].split('=');
                          vars.push(hash[0]);
                          vars[hash[0]] = hash[1];
                        }
                        return vars;
                      },
                      getUrlVar: function(name){
                        return $.getUrlVars()[name];
                      }
                    });
                        var from = $.getUrlVar('from');
                        var to = $.getUrlVar('to');
                          $('#to').val('going to ' + to);
                          $('#from').val('coming from '+from);
         $("#msgBox").trigger();
        });
       $("#msgBox").append("&lt;form id='myForm' method='post' action='index.php'&gt;&lt;div style='border:1px solid #cc0; width:300px;'&gt;&lt;input type='text' id='from' name='from'&gt;&lt;input type='text' id='to' name='to' &gt;subject:&lt;input type='text' name='subject'&gt;&lt;br&gt;message:&lt;textarea class='mbox' name='msg'&gt;&lt;/textarea&gt;&lt;br&gt;&lt;input type='submit' value='submit'&gt;&lt;/div&gt;&lt;/form&gt;");
&lt;/script&gt;
</code></pre>
