tags:

views:

319

answers:

2

Hi!!

I have a form and the "Name" input text is using jQuery autocomplete. What I needed was when I select a name in the list result of autocomplete, I fill the other input texts (date of birth, telephone etc) based upon the name selected.

Does anyone know how to make this second ajax call after a name is chosen?

thanks!!

A: 

Assuming the select ID from where the names are is "thenames", you can do something like:

$("#thenames").change(function (){
  var params = {
    "id": $(this).val()
  };

  $.getJSON("person_details.php", params, function (jsonData){
    // Fill the rest of input texts.
  });
});
Seb
A: 

You'll need to give the input that has the autocomplete plugin applied to it an ID. For example, "myNames". The others could be "myDOB" and "myTelephoneNum".

$("#myNames").change(function() {
  $.ajax({
    url: "getRestOfData.cfm",
    data: {newSelection:$(this).val()},
    success: function(data) {
      data = $.trim(data);
      //from here just fill in the rest of the fields with the received data
      //$("myDOB").val("");
      //$("myTelephoneNum").val("")
    }
  });
});
GlenCrawford