title: Using Jquery to dynamically create objects
body: <p>I'm trying to dynamically create objects out of forms, but I want some reduntant elements to be ommitted, such as the submit.  </p>
  
  <p>The only problem is that my function won't omit these fields.</p>
  
  <pre><code>    function form_to_json(formname) {
  
      var obj = new Object();
  
      var identity = "#" + formname + " input";
  
  // Create JSON strings ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  
      $(identity).each(function() {
  
          if ($(this).val() != "Submit" || $(this).attr('name') != "password2") {
  
              var propertyName  = $(this).attr('name');
              var propertyValue = $(this).val();
  
              eval("obj." + propertyName + "='" + propertyValue + "'");               
          }
      });
  
      var jsonObj = JSON.stringify(obj);
  
      return jsonObj;
  }
  </code></pre>
  
  <p>The output spits out a nice little json object the only problem is it doesn't omit the form elements I'm asking it to.</p>
  
  <p>Is it something to do with the selectors?</p>