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 8726877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:20:06+00:00 2026-06-13T08:20:06+00:00

I have a database table with vehicles in it and they’re separated into columns

  • 0

I have a database table with vehicles in it and they’re separated into columns by year, make, model, and trim.

I’d like to create a form where a user can select the year, then the make, then the model, then the trim with each selection (except for year) taking into consideration the selection before it.

Is there a way to do this? What would it look like?

  • 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-13T08:20:08+00:00Added an answer on June 13, 2026 at 8:20 am

    Well, you have lots of different ways to do it.

    I would do the following way:

    $("#year']").click(function(){
      var url = '/get_make_values?year=' + $(this).val()
      $("#group").removeOption(/./)
      $.get(url, function(data) {
        $('#group').addOption(data, false);
      });
    });
    

    In your controller,

    def get_make_values
      val = params[:year]
      #Use val to find records
      options = Vehicles.collect{|x| "'#{x.id}' : '#{x.label}'"}    
      render :text => "{#{options.join(",")}}" 
    end
    

    In your models you can define some scopes:

    class Vehicle < ActiveRecord::Base
      scope :by_year, lambda {|v| where(:year => year)}
      ...
    end
    

    Hope this helps!

    Regards

    Edit:

    I’ll explain in parts

    In the javascript I’m associating an event to the list of year, then I make a GET request to a controller action that get all make values. Then I fill the MAKE list with it
    You should do it to make, model and trim also

    In the controller I’m creating a method to retrieve the make values (that is called by the get method). You’ll have to do it for the other retrieved values also. Model and trim.

    In the model I just suggested a resource that you may use to facilitate the queries that is the scope feature.

    Please accept my reply!

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

Sidebar

Related Questions

I have two tables, a vehicle table with columns: id stock year make model
i have database table like this +-------+--------------+----------+ | id | ip | date |
that my problem: I have database table like that: id (AI) market_id 1 6
I have a database table named Categories . I want to create a form
I have one database table which contains 8 columns. One of the columns is
In my database table I have the following fields: Table Supplier: id name vehicles
I have database table: DROP TABLE translation_en_lt; CREATE TABLE translation_en_lt ( id INTEGER, lt_translation
I have a database table named call with columns call_time, location, emergency_type and there
Hi I have database table struture Like following table - ItemLocation ItemId varchar(10) ItemGeo
I have a database which has a table recording when a vehicle was last

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.