1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Autocomplete search form issue

Discussion in 'Templates, HTML, CSS, and Design Help' started by jason1971, Oct 10, 2015.

  1. jason1971 Customer

    Hi guys,

    I have found an excellent search form, which shows a drop down list of options as you type, with links to relevant pages.
    http://www.w3schools.com/php/php_ajax_livesearch.asp

    However, after setting it up exactly as it says, it does not work. So I guess my question is why? is it in some way not compatable with the 68C script?

    Cheers Jason
  2. Mike-N-Tosh Owner

    Jason,

    This code is set to read a file, "links.xml" which is where the actual data is stored. So when the form field is being typed into, it triggers a javascript that loads a php file which queries the ".xml" file where the actual data lives. The query result from the ".xml" file is then is returned to the ".php" file which then returns that data to the javascript which injects the returned html code into the "live search" div element in the html file.

    As the data in 68 Classifieds is in a database and not a file, you would need to query the database table(s) either directly or through the "Listings.php" class file as the quick search and the advance search does.

    I personally wouldn't recommend doing this on a shared hosting web service and/or a busy classifieds site with a lot of visitors and listings as this would be a lot of server intensive processing. (That's why the example uses an ".xml" data file with only 6 data points in it to begin with)

    It certainly is possible to do, but it's not easy and it would be most likely better done through ajax than the DOM as it is done in your example. For more guidance and reference, look at the advance search. Specifically, the category and extra fields functionality. This is exactly what it does.

    The category select field which is named "type". The javascript checks when the "type" field changes. When it changes, it uses ajax to send the type (category) to the ajax.php file as post (as if you submitted a form). The ajax file uses a function that queries the database directly and then returns the result back to the javascript. The javascript then injects the results right back into the search.tpl (html) file in the response div.
  3. jason1971 Customer

    Thanks Mike, I think it as you said I will give it a miss. But thank you for the advice once again.

Share This Page