title: Jquery passing a parameter between functions
body: <p>Hey i would to pass a parameter from a function in jquery, but i cant get it to work. what am I doing wrong? I would like to pass "name" from the click function to the dialog block function to prevent repeating of code</p>
  
  <p><strong>Update:</strong> I have define name after the function. however i still cannot pass it like this &lt;%=GetUserName(name)%></p>
  
  <p><strong>Update 2</strong> jsFiddle link  <a href="http://jsfiddle.net/bbKw8/" rel="nofollow">http://jsfiddle.net/bbKw8/</a></p>
  
  <pre><code>            &lt;div id="dialog-block" &gt;
                  &lt;p&gt;
                      &lt;b&gt;Friends List:&lt;/b&gt;
                      &lt;% =GetFriends(0) %&gt;
                  &lt;/p&gt;
              &lt;/div&gt;
              &lt;div id="Div1"&gt;
                  &lt;p&gt;
                      &lt;b&gt;Friends List:&lt;/b&gt;
                      &lt;% =GetFriends(0) %&gt;
                  &lt;/p&gt;
              &lt;/div&gt;
              &lt;script type="text/javascript"&gt;
  
                  // the jQuery document ready handler
                  $(function () {
                      var name;
                      // create our dialog
                      $('#dialog-block').dialog({
                          title: '&lt;%=GetUserName(name)%&gt;',
                          autoOpen: false,
                          width: 400,
                          buttons: {
                              "Close": function () {
                                  closeDialog($(this))
                              }
                          }
                      });
  
                      // the button to open the dialog
                      $('#user0chair,#apDiv1').click(function (event) {
                          if (this.id == 'user0chair') {
                              $('#dialog-block').dialog('open');
                              name = 1;
                          }
                          else if (this.id == 'user1chair') {
                              $('#dialog-block').dialog('open');
                          }
                      });
  
                  });
  
                  function closeDialog(elem) {
                      elem.dialog("close");
                  }
              &lt;/script&gt;
  </code></pre>