|
var courseObj = null;function loadCourse() {new Ajax.Request("getCourse.do", {method :"get",onSuccess : function(resp) {courseObj = resp.responseText.evalJSON();fillCourse();}});}/* * 填充分类和产品 */function fillCourse() {if (courseObj != null) {var courseSelect = $('course');for (i = 0; i < courseObj.length; i++) {courseSelect.options[i] = new Option(courseObj[i].name,courseObj[i].id);}courseSelect.options[0].selected = true;fillSubject(courseObj[0].subjects);}}function fillSubject(subjectObj) {var subjectSelect = $('subject');subjectSelect.length = 0;for (i = 0; i < subjectObj.length; i++) {subjectSelect.options[i] = new Option(subjectObj[i].name,subjectObj[i].id);}}/* * 变更分类 */function changeCourse(index) {var courseSelect = $('course');courseSelect.options[index].selected = true;fillSubject(courseObj[index].subjects);} |
|