Hi there,
I've hit a brick wall in the sense that I can't seem to think up the logic required to perform this task.
Basically I have a number of rows that are populated by a MySQL database. There are a few columns which a user must fill in to update certain information which are input fields. Without using Jquery/Ajax, everything is working fine. The only issue is that, to make data entry easier, autocomplete these fields based on a first name entered. This first name entered retrieves information from a MySQL database via PHP and Jquery autocomplete.
I have this working well when only one row is modified but as you can imagine there are many rows on a page and each one needs to be validated separately.
Here is the Jquery which works on a single row.
Here is an example of the HTML:Code:<script type="text/javascript"> $(document).ready(function(){ $('input#inst_fname').autocomplete({ source: "contractor_prefill.php", minLength: 1, select: function(event, ui) { $('#inst_suburb').val(ui.item.suburb); $('#inst_state').val(ui.item.state); $('#inst_lname').val(ui.item.second_name); $('#inst_unit_type').val(ui.item.unit_type); $('#inst_num').val(ui.item.unit_no); $('#inst_street_num').val(ui.item.street_no); $('#inst_street_name').val(ui.item.street_name); $('#inst_street_type').val(ui.item.street_type); $('#inst_postcode').val(ui.item.postcode); $('#inst_phone_num').val(ui.item.phone_no); } }); }) ; </script>
I understand that you need unique IDs for this to work but this is where I fall short. I tried to use classes but that just duplicated the data on all rows. I have even started thinking about using for loops but it's starting to get messy.Code:<input type=\"text\" name=\"inst_fname[]\" id=\"inst_fname\" ></td> <td> <input type=\"text\" name=\"inst_lname[]\" id=\"inst_lname"\"></td> <td>
If anyone can point me in the right direction I would be truly grateful.
Thanks.


Reply With Quote
Bookmarks