Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8002109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:16:04+00:00 2026-06-04T16:16:04+00:00

Jquery’s autocomplete documentation seems to be a bit lacking, at least for beginners. I’ve

  • 0

Jquery’s autocomplete documentation seems to be a bit lacking, at least for beginners. I’ve scoured the net for good tutorials, but haven’t found any.

Heres what I have so far:

HTML:

<div id="addfilter">
    <div id="textwrap">
    <form method="POST" class="homeForm" id="homeForm" action="<?php echo base_url() ?>main/add_filter">
        <input type="text" class="text" id="homeText" name="homeText" placeholder="Add Category"></input>
        <input type="image" class="imginput" src="<?php echo base_url() ?>img/board/icons/add.jpg"id="homeSubmit" value="X"></input>
    </form>
    </div>
</div>

JS:

$().ready(function() {
    $("text").autocomplete("search.php", {
        width: 260,
        matchContains: true,
        selectFirst: false
    });
});

search controller

    public function search()
    {
        $this->thread_model->autocomplete();
    }

autocomplete model

    public function autocomplete()
    {
        $query = $this->db->query('SELECT tag
            , COUNT(*) as num_items
            FROM filter_thread ft
            INNER JOIN filter f
            ON ft.filter_id = f.filter_id
            GROUP BY tag');
        $tagcloud = $query->result_array();
        foreach ($tagcloud as $tags)
        {
            echo $tags;
        }
    }

Firebug doesn’t show anything happening when I input text into ‘formText.’ I’m not even sure if the output of the model is in the correct format. Any help would be appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T16:16:05+00:00Added an answer on June 4, 2026 at 4:16 pm

    Have you tested your controller and model?

    First of all I’d correct your jquery:

    $(document).ready(function() {
            var url = $("#homeForm").attr("url");
            $("#homeText").autocomplete({
                source: url,
                width: 260,
                matchContains: true,
                selectFirst: false
            });
        });
    

    I’d recomment to supply URL the other way like attribute in form tag:

    <form url="<?php echo base_url() ?>main/search" .... >
    

    And before autocomplete in jQuery get that URL:

    var url = $("#homeForm").attr("url")
    

    Autocomplete then sends constraint by in term parameter. You shoud adjust your query to something like that:

    'SELECT tag, COUNT(*) as num_items
                FROM filter_thread ft
                INNER JOIN filter f
                ON ft.filter_id = f.filter_id
                WHERE <YOUR_FIELD_HERE> LIKE("%'.$this->db->escape($_POST['term']).'%")
                GROUP BY tag'
    

    I’m not really familiar with CodeIgniter, so you maybe need to correct something.

    And the last (maybe) thing is to see how autocomplete will react with returns.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

jQuery autocomplete plugin shows results that begin with the query you type into a
jQuery and JavaScript in general are new ground for me. What are some good
jQuery selectors are wonderful, but I sometimes I find myself typing them over and
Jquery UI autocomplete wont work,what could be wrong?Here is the code.Thank you <head> <meta
jQuery.unique lets you get unique elements of an array, but the docs say the
jQuery's effects are great, but I've noticed that the remaining elements under the affected
jQuery can return last or first child,it works ok. But I need to get
jquery datepicker is a great fun but I am facing a weird error. I
Jquery UI Dialog modal-form doesn't shows up inside table, but works fine outside. This
jQuery Autocomplete works by putting a select box on the page and doing this:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.