当前位置: 代码迷 >> Web前端 >> select 联系关系选取
  详细解决方案

select 联系关系选取

热度:237   发布时间:2012-11-13 10:00:50.0
select 关联选取
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);
	}

?

  相关解决方案