title: JQuery & AJax: passing data variables with form element
body: <p>I have a form that is populated with dynamic form elements based on a "SecID" variable which identifies which section of the site the user is in.</p>
  
  <p>I'm using classic ASP, with JQuery &amp; AJAX to save the form changes.  It's working great so far with this code:</p>
  
  <pre><code>&lt;form name="sampleForm" ID="sampleForm"&gt;
              &lt;input type="hidden" name="SecID" id="SecID" value=&lt;%=SecID%&gt;&gt;
  
              &lt;input type="text" value="&lt;%=rs.fields("Title")%&gt;" name="Title" class="formJD"&gt;
  
              &lt;input type="text" value="&lt;%=rs.fields("JobCode")%&gt;" name="JobCode" class="formJD"&gt;
              &lt;select name="&lt;%=TypeID%&gt;-&lt;%=RowID%&gt;" class="&lt;%=FormClass%&gt;"&gt;
                          &lt;option value=""&gt;Select&lt;/option&gt;
                          &lt;option value="1"&gt;Example 1&lt;/option&gt;
                          &lt;option value="2"&gt;Example 2&lt;/option&gt;
              &lt;/select&gt;
  &lt;%'***more form elements taken out to be short****%&gt;
  &lt;/form&gt;
  
  &lt;script&gt;
  
  
  function showValues() {
    var str = $("#sampleForm").serialize();
                  $.ajax({
                       type: "POST",
                       url: "updateFormAJAX.asp",
                       data: str,
                       success: function(msg) {
                          // $('#autosavenotify').text(msg);
                       }
                  });
  
  }
  
  $(":checkbox, :radio").click(showValues);
  $("select").change(showValues);
  $("input").change(showValues);
  showValues();
  &lt;/script&gt;
  </code></pre>
  
  <p>I'll leave out the ASP page that is called by AJAX.  This is all working fine to update the entire form on each change.  The problem I'm having is that since I'm using serialize() to pass the elements to AJAX it's saving the ENTIRE form with each change of a form element.  This is ok for smaller pages, but some pages the form can be huge and saving the form 20+ times is going to slow things down.</p>
  
  <p>What I'd like to do is just save individual form elements when they are changed instead of the entire form.  I've tried to do that with a function like this:</p>
  
  <pre><code>&lt;script&gt;
      $(document).ready(function(){
      $('select').live('change',function () {
              var statusVal = $(this).val();
              //alert(statusVal);
              $.ajax({
                       type: "POST",
                       url: "saveStatus.asp",
                       data: "statusType=statusVal",
                       success: function(msg) {
                          // $('#autosavenotify').text(msg);
                       }
            })
        });
      });
      &lt;/script&gt;
  </code></pre>
  
  <p>I had that working too, but I'm not sure how I can pass other variables to my AJAX update page that will be needed to save to the database.  For example in the version I posted above I'm able to pass the "SecID" variable and since I'm using serialize() it will send everything.  But if I only want to send a change to a single form element at a time, but also include the "SecID" variable or additional variables, how would I change this to accomplish it?</p>
  
  <p>Thanks for any help!</p>