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

  • Home
  • SEARCH
  • 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 6900253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:31:21+00:00 2026-05-27T07:31:21+00:00

Im looking for an autocomplete ajax implementation for a textfield. you type your city

  • 0

Im looking for an autocomplete ajax implementation for a textfield.

  • you type your city
  • it wil look for closest match in db as you type
  • as soon as it finds the city (partially search) it displays some options to choose from in format city, state you can pick one from the list and the textfield would contain ” city, state”

What would be good ways of doing this in rails?
I think i need an autocomplete functionality for this with an ajax posting to the app

  • 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-05-27T07:31:22+00:00Added an answer on May 27, 2026 at 7:31 am

    You can find the relevant JavaScript (assuming you’re using JQuery) here, from there it’s just a matter of setting up a controller action that returns some json and inserting the path to that action to the source: option.

    So, very approximately, you’d do something like:

    controller:

      class CityController << ApplicationController
    
        def lookup
          cities = City.find_by_name(params[:city])
          render :json => cities
        end
    
      end
    

    view:

    <%= form_tag do %>
      <%= text_field_tag('city', :id => 'city_input') %> 
      <script type='text/javascript'>
        $(function() {
    
          $( "#city_input" ).autocomplete({
            source: "<%= lookup_cities_path %>",
            minLength: 2
          });
        });
      </script>
    <% end %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking for a Javascript autocomplete implementation which includes the following: Can be
I'm looking for a Combo(Viewer) in SWT/JFace which supports autocomplete / type-ahead, i.e. the
I'm looking into using the jQuery UI autocomplete widget to implement user lookup by
I'm looking for a good way to get autocomplete and click-for-reference (whatever that's called)
I am creating an Ajax autocomplete application and would like know if there is
I am looking for an autocomplete ( or autosuggest) that is good for a
I'm using asp.NET MVC, and am looking at the JQuery autocomplete plugin for what
I'm looking for a library for Autocomplete support in text controls which remembers all
I am looking for a plugin that provides the autocomplete feature using jQuery Mobile?
I'm looking at this jQuery Autocomplete example . What I can't figure out is

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.