我有一个Grade
带有值的下拉列表
["a", "b", "c"]
在下拉列表的选择更改时,Student
应加载下拉列表的值。
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"]
我们可以将所有成绩和学生保存在单个数组中(在 js 文件中)吗?如果是,我怎样才能从数组中仅加载在 javascript 中更改的选定索引上的那些值?
添加到描述中,我的代码是 HTML,所以我的控件是:
<select id="grade" name="grade"></select>
<select id="student" name="student"></select>
修改的 :
var grades_rank;
var grades_student;
var grades = { "very good": ["Anna", "Hannah"], "good":
["Billy", "Cathy"], "above average": ["Albert", "Deepti"] } ;
要加载下拉列表:
for (var _i = 0; _i < grades.length; _i++) {
jQ('#Stu_Grades').append(jQ("<option></option>").attr("value", _i).text(grades[_i][grades_rank]));
}