Skip to content Skip to sidebar Skip to footer

Unable To Fill The Other Fields On The Basis Of Option Selected

I want to fill the other fields on the form from database on the basis of option selected, but unable to do using php and javascript.I have attached json data I received in questio

Solution 1:

First of all remove or comment $("#applicant_salutation").val(res.ho_salutation) and $("#applicant_district").val(res.ho_citizenship_district) line in from your javascript code bcoz both id is not available in your html.

Also add dataType: 'json' in you ajax request

As i have checked applicant_wardno is select box and you have to set selected for displaying value in the select box instead of setting val.

check this link for setting selected value

Solution 2:

You can debbug with an alert: alert(res.ho_wardno); and see if the value is being returned from the ajax query;

      $("#applicant_wardno").val(res.ho_wardno);
      alert(res.ho_wardno);
      $("#applicant_citizenship_no").val(res.ho_citizenship_number);
      $("#applicant_phone").val(res.ho_phone);

Post a Comment for "Unable To Fill The Other Fields On The Basis Of Option Selected"