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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:03:21+00:00 2026-05-26T22:03:21+00:00

Is it compulsory that all dynamic dropdown menus must be called from the database?

  • 0

Is it compulsory that all dynamic dropdown menus must be called from the database? I want to include one for my latest project, although I dont know how to do it, but after searching from Google, I found that almost everyone was talking about MySQL. I was thinking <select name=""> would be enough.

  • 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-26T22:03:21+00:00Added an answer on May 26, 2026 at 10:03 pm

    A database is definitely useful, but not strictly required.

    I have a jQuery javascript I often use for dynamic drop-downs. It updates the drop-downs from a javascript variable (json object). Most often I generate this from a database, but it could be hard coded if the site doesn’t use a database.

    Edit (adding explaination)

    I’ve updated the sample code to be somewhat more related to your application (only knowing it relates to classes and sessions. The example has dynamic dropdowns as follows:

    • Select course
    • Select the semester
      • Depending on the course some course may have multiple options or only run in one particular semester. Also a ‘full year project’ for which semester is not applicable.
    • Select daytime/evening classes
      • This may only be applicable to some courses

    (A few levels of dynamic, just to cover the script capabilities)

    Now the implementation. We include a script at the top of the page (+ jQuery, which the script depends on). Then we have the HTML, we only need empty select fields with names and ids. The dynamic options are handled by the javascript.

    The onload is the only javascript that needs to be modified for the application. We have an array of ‘option’ objects with their id, parent_id, and display.

    And the jquery onload function adds the options into the dropdown and if course changes then semester dropdown should update, and if semester dropdown then time dropdown is updated.

    The scripts has one additional property in that it hides the field and it’s label if there are no related options for a given selection.

    A complete html page combining these parts can be viewed here: http://snipt.org/Uul0 (Just sav to an html file to demo it)

    So this shows how you can easily create dynimic dropdowns without a database and even without server side code (PHP). This is purely JQuery and HTML). Now, that said, I’m not saying you are better off without a database, just that it’s not strictly needed for dynamic dropdowns.

    Sorry this is already a long essay. That’s all I have to offer here.

    The included script

    function loadOptions(jquery_identifier, options, parent_id)
    {
        var $select = jQuery(jquery_identifier),
            i, option;
        $select.children().remove();
    
        if (typeof(options)=='object'&&(options instanceof Array))
        {
            var toAppend = [];
            var toAppendIndex = 0;
    
            for (i = 0; i < options.length; i++)
            {
                option = options[i];
    
                if (option.parent_id == parent_id)
                {
                    // repeatedly appending to select was too slow, instead
                    // appending to array and appending to select once at the end using toAppend.join
                    toAppend[toAppendIndex++] = "<option value='";
                    toAppend[toAppendIndex++] = option.id;
                    toAppend[toAppendIndex++] = "'>";
                    toAppend[toAppendIndex++] = option.display;
                    toAppend[toAppendIndex++] = "</option>";
                }
            }
    
            if (toAppendIndex > 0)
            {
                $select.append("<option value='' selected='selected'>- Select -</option>").append(toAppend.join(''));
                $select.parent('.field').show();
            }
            else
            {
                $select.parent('.field').hide();
            }
        }
    
        $select.change();
    }
    

    Sample usage

    The HTML

    <div class='field'>
        <label for='course'>Course</label>
        <select name='course' id='course'></select>
    </div>
    
    <div class='field'>
        <label for='semester'>Semester</label>
        <select name='semester' id='semester'></select>
    </div>
    
    <div class='field'>
        <label for='time'>Time</label>
        <select name='time' id='time'></select>
    </div>
    

    The onload

    var dynamic_options = [
        {"id":"1","parent_id":"0","display":"Database fundamentals"},
            {"id":"2","parent_id":"1","display":"Semester 1"},
            {"id":"3","parent_id":"1","display":"Semester 2"},
                {"id":"4","parent_id":"3","display":"Daytime classes"},
                {"id":"5","parent_id":"3","display":"Evening classes"},
        {"id":"6","parent_id":"0","display":"Games technology"},
            {"id":"7","parent_id":"6","display":"Semester 1"},
            {"id":"8","parent_id":"6","display":"Semester 2"},
        {"id":"9","parent_id":"0","display":"Industry project (full year)"}
    ];
    
    
    jQuery(function(){
    
        // initialise course dropdown with the choices with no parent (parent_id = 0)
        loadOptions('#course', dynamic_options, 0);
    
        // if course changes update semester dropdown with the appropriate child options
        jQuery('#course').change(function() {
            loadOptions('#semester', dynamic_options, jQuery(this).val());
        }).change();
    
        // if level 2 changes update level 3 with the appropriate child options
        jQuery('#semester').change(function() {
            loadOptions('#time', dynamic_options, jQuery(this).val());
        }).change();
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two dropdown lists (one dynamically populated, the other not) that determine the
In my database, I have a lot of courses that are compulsory. Some are
I am using Java Communications API . Want to know that is it compulsory
There were some windows opened, And from my process I want to launch one
With the CheckListBox in VB.NET in VS2005, how would you make it compulsory that
I am working on a project that requires me to generate a java .class
i'd like to make a javascript validation that will accept all numeric and decimal
As of August 15, Amazon made it compulsory to sign all requests made to
Before i start must explain that I'm relatively a noob with less experience in
Background Sweden is transitioning to a compulsory law for all business owners handling cash

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.