title: jQuery autocomplete: change SQL query depending on selected checkbox
body: <p>imagine i have one textbox (with autocomplete 1.1, not the latest UI version) and a checkbox.
  The textbox triggers an asp.net .ashx page that will execute a stored procedure at the sql-server and return the results.</p>
  
  <p>It's all working, but i want to add another feature.
  When the checkbox is checked i want stored_procedure_1 to be executed.
  If the checkbox is unchecked, stored_procedure_2 must be executed.
  The checkbox is unchecked by default.</p>
  
  <p>My question:
  How do i tell the ashx page if the checkbox is checked or not..?
  By default the autocomplete will trigger something like: <em>autocompletedata.ashx?q=myname</em> and that will execute stored_procedure_2, but when the checkbox is checked it must trigger <code>autocompletedata.ashx?q=myname&amp;mycheckbox=begin</code> so that stored_procedure_1 will be executed.</p>
  
  <p>Do i have to add some jQuery code to pass the checked checkbox?
  I am totally lost..</p>
  
  <p>Thanks in advance.</p>
  
  <p><strong>Form elements:</strong></p>
  
  <pre><code>&lt;input id="search_employee" type="text" class="employee" /&gt;
  &lt;input type="checkbox" name="mycheckbox" value="begin" /&gt;
  </code></pre>
  
  <p><strong>jQuery:</strong></p>
  
  <pre><code> $().ready(function() {
  
          $("#search_employee").autocomplete("includes/AutocompleteData.ashx", {
              minChars: 3,
              max: 15,
              selectFirst: false,
              scrollHeight: 300,
              formatItem: function(data, i, n, value) {
              if (value.split("_")[3]!== null)
              {
              return "&lt;img style = 'width:40px;height:53px;float:left; margin:2px 5px 2px 0' src='/pictures/thumbs/"
              + value.split("_")[3] + "'/&gt; " + value.split("_")[0] + "&lt;br /&gt;&lt;span class=smallname&gt;" + value.split("_")[2] + "&lt;br/&gt;" + value.split("_")[4] + "&lt;/span&gt;";
          } 
      },
              formatResult: function(data, value) {
                  return value.split("_")[0];
              }
          });
  </code></pre>
  
  <p><strong>Part of autocompletedata.ashx :</strong></p>
  
  <pre><code>Dim searchname As String = context.Request.QueryString("q")
  Dim searchstart as string = context.Request.QueryString("mycheckbox")
  Dim searchsql as string
  
  if searchstart = "begin" then
     searchsql = "stored_procedure_1"
  else
     searchsql = "stored_procedure_2"
  end if
  
  Dim conn As SqlConnection = New SqlConnection
  conn.ConnectionString = ConfigurationManager.ConnectionStrings("MyConn").ConnectionString
  Dim cmd As SqlCommand = New SqlCommand
  cmd.CommandType = Data.CommandType.StoredProcedure
  cmd.CommandText = searchsql.ToString
  cmd.Parameters.AddWithValue("@SearchText", searchname)         
  </code></pre>