title: Encode a string to pass as a parameter
body: <p>I have this function:</p>
  
  <pre><code>function eLookup(type, long, lat, distance) {
  //var sFilter = getCompanyProductFamilies();
  
  distance = distance * 1000;
  $.ajax({
      url: O.GenURL('xtmp_Maps/Get' + type + '.asp', 'long=' + long + '&amp;lat=' + lat + '&amp;distance=' + distance),
      success: eval('plotEntity' + type)
  });
  </code></pre>
  
  <p>}</p>
  
  <p>I have another function called getCompanyProductFamilies which I have commented out the call for in the above function as there is something wrong and this is partly where I'm stuck.</p>
  
  <pre><code>function getCompanyProductFamilies()
  {
    var cb = document.getElementsByClassName("PRODFAM");
    var sAnd = "";
  
    for(var i = 0; i &lt; cb.length; i++)
    {
      sAnd += "comp_c_productfamily like '%," + cb[i].id.replace("pdfam_", "") + ",%' or ")
    }
  
    if(cb.length &gt; 0)
    {
      sAnd = sAnd.slice(0, -4);
      sAnd = " and (" + sAnd + ")";
    }
  
    return sAnd;
  }
  </code></pre>
  
  <p>The above function should get all checkboxes with the class name of PRODFAM, and for each one that is checked, it should slowly generate part of a where clause for a SQL statement. I am aware of the implications of SQL injections, but this is not something on the open internet, so ignore that. I tried several ways of getting the checked ones using jQuery but nothing I did worked.</p>
  
  <p>An example of the HTML it is working on is here:</p>
  
  <pre><code>&lt;input type="checkbox" id="pdfam_711121" class="PRODFAM"/&gt;
    &lt;label for="pdfam_711121" class="VIEWBOX"&gt;Local Wage Rate&lt;/label&gt;&lt;br /&gt;
  &lt;input type="checkbox" id="pdfam_711131" class="PRODFAM"/&gt;
    &lt;label for="pdfam_711131" class="VIEWBOX"&gt;Temporary Staff&lt;/label&gt;&lt;br /&gt;
  &lt;input type="checkbox" id="pdfam_711341" class="PRODFAM"/&gt;
    &lt;label for="pdfam_711341" class="VIEWBOX"&gt;Other Contractors&lt;/label&gt;&lt;br /&gt;
  </code></pre>
  
  <p>There are about 25 of the above categories, and this is just 3 as an example. The number of categories could change as well. What I need my my function(s) to do is:</p>
  
  <p>Get a list of checkbox IDs that are checked and construct a string that can be passed as a parameter to the ajax call in the top function. When the parameter is received by the target of the ajax call, I can put a function in that page that creates the where clause for the SQL call.</p>
  
  <p>Any help would be most appreciated. The top function called eLookup can't change too much but I can add querystring parameters, which is what I want to do. The other function it doesn't matter about that.</p>