Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: Year Make Model

  1. #1
    Regular Coder
    Join Date
    Dec 2005
    Posts
    346
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Year Make Model

    I am currently working on a Auto Repair type of site that allows a user to keep track of his vehicle maintenance. I have hand coded the year & make for the drop down menu. I am not working on a page that would allow the user to add a new vehicle to his account. I need to know if there is a site or code that would auto populate the model based on the year & make selected?

    I want the user to be able to select the year, then the make, & then the model of their vehicle...

    An example is something like this but in the form of a drop down menu:

    http://www.partsamerica.com/VehicleS...aspx&year=1995

    When you click on the auto maker Dodge...It displays every vehicle made by Dodge in 1995...the link above if for the year 1995. I have the year selection on my site in a drop down menu option. I want all of this to be automatic in populating the models. I don't want to have to type every single model made by every auto make out there for every year. On that same site above it list the vehicles by year also...if you choose a year of 1970 & make as Dodge you wont find Dakota for instance because they didn't make Dakota until 1987.

    I have searched google & yahoo & the different web coding forums. Nothing helps...I would think that this is a simple coding since they are sooo many auto parts sites out there....

    Thanks!

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,640
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Take a look at http://www.felgall.com/jstip22.htm for the Javascript to dynamically populate one dropdown based on the selection in another.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    Regular Coder
    Join Date
    Dec 2005
    Posts
    346
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by felgall
    Take a look at http://www.felgall.com/jstip22.htm for the Javascript to dynamically populate one dropdown based on the selection in another.
    Thanks!!! I like that even if I have to manually type everything in. I have a couple of questions about that script...

    In these lines:
    PHP Code:
     function setOptions(chosen) {
    var 
    selbox document.myform.opttwo;
     
    selbox.options.length 0;
    if (
    chosen == " ") {
      
    selbox.options[selbox.options.length] = new Option('Please select one of the options above first',' ');
     
    }
    if (
    chosen == "1") {
      
    selbox.options[selbox.options.length] = new Option('first choice - option one','oneone');
      
    selbox.options[selbox.options.length] = new Option('first choice - option two','onetwo');
    }
    if (
    chosen == "2") {
      
    selbox.options[selbox.options.length] = new Option('second choice - option one','twoone');
      
    selbox.options[selbox.options.length] = new Option('second choice - option two','twotwo');
    }
    if (
    chosen == "3") {
      
    selbox.options[selbox.options.length] = new Option('third choice - option one','threeone');
      
    selbox.options[selbox.options.length] = new Option('third choice - option two','threetwo');
    }

    This part in the lines 'oneone' 'onetwo' 'twoone' 'twotwo' 'threeone' & so on & so on...what does that part of the coding do? Is is needed?

  • #4
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,640
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Option('first choice - option one', 'oneone')

    translates to

    <option value="oneone">first choice - option one</option>

    ie. the first parameter is the entry to display and the second parameter is the value that will be passed if it is selected.

    The values of chosen will be the values of the option selected from the other dropdown.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #5
    Regular Coder
    Join Date
    Dec 2005
    Posts
    346
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by felgall
    Option('first choice - option one', 'oneone')

    translates to

    <option value="oneone">first choice - option one</option>

    ie. the first parameter is the entry to display and the second parameter is the value that will be passed if it is selected.

    The values of chosen will be the values of the option selected from the other dropdown.
    Thanks!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •