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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:45:26+00:00 2026-06-13T01:45:26+00:00

I have a dropdown Grade with values [a, b, c] On selection change of

  • 0

I have a dropdown Grade with values

["a", "b", "c"]

On selection change of dropdown, the values of Student dropdown should be loaded.

when "a" is selected, Dropdown students should populate ["Anna", "Hannah"]
When "b" is selected, Dropdown students should populate ["Billy", "Cathy"]
When "c" is selected, Dropdown students should populate ["Albert", "Deepti"]

Can we keep all the grades and students in single array(in js file)? If yes, how can I load only those values on selected index changed in javascript from the array ?

To add to the description, my code is in HTML, so my controls are:

 <select id="grade" name="grade"></select>
 <select id="student" name="student"></select>

Modified :

    var grades_rank;
    var grades_student;
    var grades = {     "very good": ["Anna", "Hannah"],     "good":
 ["Billy", "Cathy"],     "above average": ["Albert", "Deepti"] }  ;

To load the dropdown:

for (var _i = 0; _i < grades.length; _i++) {
            jQ('#Stu_Grades').append(jQ("<option></option>").attr("value", _i).text(grades[_i][grades_rank]));
        }
  • 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-13T01:45:27+00:00Added an answer on June 13, 2026 at 1:45 am

    Use an object:

    var grades = {
        a: ["Anna", "Hannah"],
        b: ["Billy", "Cathy"],
        c: ["Albert", "Deepti"]
    }
    

    When the dropdown value changes, use its new value to lookup the names you want to use:

    grades[a]; // ["Anna", "Hannah"]
    grades[b]; // ["Billy", "Cathy"]
    

    When all is said and done, it might look something like the following:

    // Lookup chart for grades and students
    var grades = {
        a: ["Anna", "Hannah"],
        b: ["Billy", "Cathy"],
        c: ["Albert", "Deepti"]
    }
    
    // Reference our dropdown lists
    var grade = document.getElementById("grade");
    var student = document.getElementById("student");
    
    // Add an event handler to the 'change' event on our grades
    grade.addEventListener("change", function(){
        // A few variables we'll use
        var option, g, c, i;
        // Clear student list
        while ( c = student.firstChild ) student.removeChild( c );
        // If the new value is a grade in our lookup
        if ( g = grades[ this.value ] ) {
            // Populate student list
            for ( i = 0; i < g.length; i++ ) {
                option = document.createElement("option");
                option.text = g[i];
                student.appendChild(option);
            }
        }
    }, false);​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dropdown selector, with values from 1-4. Depending on the selection, subsequent
I have three dropdown list. By default the values of all three are All.
I have an HTML control: <select id=grade> I want to get the selected value
I have dropdown on my page, I am changing selected value of dropdown from
i have a dropdown in the header and whatever the value is selected in
I have 3 dropdown selection input and one textarea input. I think it's invalid
I have dropdown box with months populated. When a month is selected I would
Here is my problem, I have dropdown which used to save the selected option
I have dropdown-Lists which have a lot of elements (>1000). When I select one
I have dropdown menu..which is dynamic.. How can get value of the last item

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.