title: Insert json data into text input
body: <p>I have a function that adds a new patient to the database, gets the json data back and then adds the new patient to the select menu.  That works fine.  I need to add that data into the corresponding text inputs i.e., input#patient_id, input#patient_firstname, etc. which should occur in the .ajax complete, but nothing happens.</p>
  
  <p>Would appreciate any help!!</p>
  
  <p>Ajax</p>
  
  <pre><code>$('#newpatient').click(function() {
  var patientadd = $('#patientaddform').serializeArray();
    $.ajax({
        url:      'adam.php',
        type:     "POST",
        data:     patientadd,
        dataType: 'json',
        success:  function(data){
                      var html = '';
                      var len  = data.length;
                      for (var i = 0; i&lt; len; i++) {
                      html += '&lt;option selected="selected" value="' + data[i].patient_id + '"&gt;' + data[i].patient_firstname + ' ' + data[i].patient_lastname + ' : ' + data[i].patient_dob + '&lt;/option&gt;';
                      }
                      alert(html);
                      $('#patientselect').prepend(html);
                      $('#patientselect').selectmenu('refresh', true);
                  }, 
        complete: function (data) {
                     for(var id in data) {        
                            $('input#' + id).val( data[id] );
                     }
                  }     
  
    });   
  </code></pre>
  
  <p>});</p>
  
  <p>json data returned</p>
  
  <pre><code>[{"patient_id":"22","patient_firstname":"","patient_lastname":"","patient_dob":"0000-00-00"}]
  </code></pre>
  
  <p>the corresponding text input fields are input#patient_id, input#patient_firstname, etc, that is why I'm trying to add the 'input#' to the id in the ajax complete and then add that val to the text input.</p>