Try this:
Code:
<script type="text/javascript">
$(document).ready(function() {
$('input.autocomplete').autocomplete({
source: "contractor_prefill.php",
minLength: 1,
select: function(event, ui) {
var p = $(this).parent(), i=ui.item;
$('.inst_suburb', p).val(i.suburb);
$('.inst_state', p).val(i.state);
$('.inst_lname', p).val(i.second_name);
$('.inst_unit_type', p).val(i.unit_type);
$('.inst_num', p).val(i.unit_no);
$('.inst_street_num', p).val(i.street_no);
$('.inst_street_name', p).val(i.street_name);
$('.inst_street_type', p).val(i.street_type);
$('.inst_postcode', p).val(i.postcode);
$('.inst_phone_num', p).val(i.phone_no);
}
});
});
</script>
And put the class 'autocomplete' only on 'inst_fname' fields.
Also, as a tip, use only one name for one thing in all programming languages concerned. For example you are referring to 'phone_num' in HTML/JS while at the same time referring to 'phone_no' in your PHP. This practice will just confuse you. and makes your code overly complicated (e.g., there's no chance to optimise this code with 'foreach' like constructs because of the irregularities). Pick one of them and stick with it throughout all languages.
Bookmarks