Need help with autocomplete script!

6 posts by 2 authors in: Forums > CMS Builder
Last Post: September 13, 2019   (RSS)

By nmsinc - September 8, 2019 - edited: September 8, 2019

The script below was written by the pros at Interactive Tools a few years back and works great! 

The result of the code in red below is what is listed in the autocomplete and is what is now recorded upon file save. I still need this information to show, however I want the account number associated with the file recorded and not the associated text!

Any ideas?

Thanks - nmsinc

   <div class="form-group">
   <label for="debtor">Name of Debtor</label>
   <input name='debtor' class='form-control' id='debtor' />
   $( "#debtor" ).autocomplete({  source: [
   <?php foreach (mysql_select("debtor", "agency ORDER BY debtor_name") as $Groups): ?>
   <?php if ($CURRENT_USER['agency'] == $Groups['agency']): ?>
   "<?php echo $Groups['debtor_name'];?> - <?php echo $Groups['debtor_address_1'];?>  <?php echo $Groups['debtor_city'];?> <?php echo $Groups['debtor_state'];?>",
   <?php endif; ?>
   <?php endforeach ?>


By nmsinc - September 11, 2019

Hi Daniel,

I like how you did this, is their a means to keep the name in the search box and pass the value upon submission?

Also, please forward a payment link and payment suggestion. Your time is worth something!

Thanks - nmsinc


By daniel - September 12, 2019

Hi nmsinc

is their a means to keep the name in the search box and pass the value upon submission?

Could you explain this in a bit more detail? E.g. what is the current behaviour, and how would you like it to change?

Also, payment is not necessary, but your support is appreciated! You can always consider making a donation the next time you upgrade CMSB :) (


PHP Programmer

By nmsinc - September 12, 2019

Once the selection is made from the autofill script the box shows the value of the record a not the autofill label text!!


By daniel - September 13, 2019

Hi nmsinc,

Oh yes, I see now what you're talking about. I think there is a way to do something like how you want, but it's rather complex with this sort of autocomplete. It actually sounds like what you want is closer to a select box than a text field. I would recommend looking at using a select dropdown with the Select2 plugin ( A select dropdown will let you use the value:label combination how you're wanting here, and the Select2 plugin adds some type-to-search functionality.

I hope that points you in the right direction; let me know if you have any further questions!


PHP Programmer