× Form Help

Autocomplete textfield - Suggestions possible values during typing from DB table

  • alexandersson
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 38
  • Thank you received: 0

alexandersson created the topic: Autocomplete textfield - Suggestions possible values during typing from DB table

Hi

I'd like to combine the flexibility of a textfield with the convenience of a selectlist to guide data entry.

To achieve this it would be great to enjoy the autocomplete functionality visible at this link:

www.devbridge.com/sourcery/components/jquery-autocomplete/

Assuming to have a textfield named "fieldA", I would like to have, during the typing, a dropdown menu that suggests all the possible values ​​that can be entered, recalling them from a table in the joomla database named "tableA" in a column named "columnA" (as in the link example).
As a user who really appreciates your work (I bought Breezing Form), I'm very surprised that you didn't think of implementing this default feature (with a specific element or script).

I attach the downloaded file from the github repository of the link.

Thank you always,
Alessandro

P.S. Today I have already sent two tickets with the same topic but, having not received confirmation from my email. Can you check? (alessandroautore@gmail.com)
#235412
Attachments:
  • MarioPuco
  • MarioPuco's Avatar
  • Away
  • Administrator
  • Administrator
  • Posts: 5741
  • Karma: 118
  • Thank you received: 530

MarioPuco replied the topic: Autocomplete textfield - Suggestions possible values during typing from DB table

Hi Alessandro,

Can you look into this topci as it has all the information that you require for this to work : crosstec.org/en/forums/1-forums/112522-d....html?start=6#173976

It won't come out of the box but basic example is there.
if you get stuck along the way, let me know.

Regards,
Mario

Satisfied with our Support ?
PayPal Tip
===============================================
Need to renew Pro Support?
Buy Here!
===============================================
Satisfied?
Consider a membership!
===============================================
Like us on Facebook
===============================================
#235419
  • alexandersson
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 38
  • Thank you received: 0

alexandersson replied the topic: Autocomplete textfield - Suggestions possible values during typing from DB table

Hi Mario.

First of all thank for your interest.

I tried without results to implement the function.

Here you can see my data, the script and the contents of the search.php file.

Can you tell me where I went wrong?
Should I also change 'term'? If yes, with which data?

=== My data ===

searchfile path = polizialocale.napoli.com/components/com_...ocomplete/search.php
dbHost = localhost
dbName = mydbname
dbUsername = mydbusername
dbPassword = mydbpassword
table name = table_autocomplete
column_name = column_autocomplete
form name = autocomplete
textfield = autocomplete

=== INITIALIZATION SCRIPT ===

function ff_autocomplete_init()
{

jQuery(function() {
jQuery( '[name="ff_nm_autocomplete[]"]' ).autocomplete({
source: ' polizialocale.napoli.com/components/com_...ocomplete/search.php '
});
});

} // ff_autocomplete_init

=== SEARCH.PHP ===

<?php
//database configuration
$dbHost = 'localhost';
$dbUsername = 'mydbusername';
$dbPassword = 'mydbpassword';
$dbName = 'mydbname';

//connect with the database
$db = new mysqli($dbHost,$dbUsername,$dbPassword,$dbName);

//get search term
$searchTerm = $_GET;

//get matched data from skills table
$query = $db->query("SELECT * FROM table_autocomplete WHERE column_autocomplete LIKE '%".$searchTerm."%' ORDER BY column_autocomplete ASC");
while ($row = $query->fetch_assoc()) {
$data[] = $row;
}

//return json data
echo json_encode($data);
?>
#235459
  • MarioPuco
  • MarioPuco's Avatar
  • Away
  • Administrator
  • Administrator
  • Posts: 5741
  • Karma: 118
  • Thank you received: 530

MarioPuco replied the topic: Autocomplete textfield - Suggestions possible values during typing from DB table

Hi,

I did not implement your code on my localhost but I can see some faults straight away.
Since you are querying column_autocomplete you need to add the following :
//get search term 
  $searchTerm = $_GET['column_autocomplete']; //this

Also in ther $query you did not add your DB table prefix table_autocomplete
$query = $db->query("SELECT * FROM table_autocomplete WHERE column_autocomplete LIKE '%".$searchTerm."%' ORDER BY column_autocomplete ASC");
while ($row = $query->fetch_assoc()) {
$data[] = $row['column_autocomplete']; // this
}

I'd suggest your go step by step carefully following the example I gave you earlier since as it seems you just need to modify your query so it's querying column_autocomplete and NOT name as in my example.

Also here is a video tutorial on how to achieve this :


Regards,
Mario

Satisfied with our Support ?
PayPal Tip
===============================================
Need to renew Pro Support?
Buy Here!
===============================================
Satisfied?
Consider a membership!
===============================================
Like us on Facebook
===============================================
#235467
Moderators: ForumSupporttomeperica
Time to create page: 0.045 seconds

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Summer Sale!

50% discount on all of our extension subscription plans & templates!

Get Your Subscription Here

News and Updates

Get informed about new downloads, updates and more in our News and Updates newsletter.

All Extensions Subscription

Get 1 year access to all of our current and future products and 1 year of professional support -- 99 for just 49! (Summer Sale)

No support per domain or website installation limits! Includes all of our current and future Joomla!® extensions, Joomla!® templates for the duration of your membership. This means, by purchasing an All Extensions Subscription you'll have it all covered!

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here