<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib uri="/WEB-INF/taglib/c.tld" prefix="c"%>
<%@ include file="../../common/init.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ include file="../../common/top.jsp"%>
<link rel="stylesheet" type="text/css" href="${ctx}/static/style/exam.css">
</head>
<body class="easyui-layout">
	<%@ include file="../../common/header.jsp"%>
	<div data-options="region:'center',title:'首页 -【考试数据维护】- 添加考试'">
		<div class="easyui-layout" data-options="fit:true,border:false">
			<div data-options="region:'center'"	style="border-color: #ccc; border-left: none;">
				<div class="row-fluid exam-add-content">
					<div class="exam-add-right span10 ">
						<div class="current-position">
							<div class="curr-nav">当前位置：新建考试-选择学生库</div>
							<c:if test="${currentStep.message != null}">
								<div class="curr-info alert alert-error">
									<a class="close" data-dismiss="alert">×</a>${currentStep.message}
								</div>
							</c:if>
						</div>
						<div class="detail-cont row-fluid">
							<form class="form-horizontal" action="${ctx}/admin/exam/selectstudent"
								method="post">
								<input type="hidden" name="examId" value="${examId}"> <input
									type="hidden" name="schoolId" value="${school.id}">
								<div class="control-group"></div>
								<div class="control-group">
									<label class="control-label" for="">学校名称</label>
									<div class="controls">${school.name}</div>
								</div>
								<div class="control-group">
									<label class="control-label" for="">级别</label>
									<div class="controls">
										<select class="span2" id="schoolLevelValue"
											name="schoolLevelValue" onchange="selectGY(this.value)">
											<option value="-1">请选择</option>
											<c:forEach items="${level}" var="l">
												<option value="${l.value}">${l.name}</option>
											</c:forEach>
										</select>
									</div>
								</div>
								<div class="control-group">
									<label class="control-label" for="">毕业年份</label>
									<div class="controls">
										<select class="span2" id="graduateYear" name="graduateYear"
											onclick="showNum(this.value)">
											<option value="-1">请选择</option>
											<c:forEach items="${graduateYear}" var="gy">
												<option value="${gy}">${gy}</option>
											</c:forEach>
										</select>
									</div>
								</div>
								<div class="control-group">
									<div class="controls">
										<label class="control-label" id="num"></label>
									</div>
								</div>
								<div class="control-group">
									<div class="controls">
										<input class="btn  btn-primary" type="submit" value="保存">
										<input class="btn" type="reset" value="清空">
									</div>
								</div>
							</form>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>

</body>
<script type="text/javascript">
	$(document).ready(function() {
	var schoolLevelValue = '${examStudent.schoolLevel.value}';
	var graduateYear = '${examStudent.graduateYear}';
	
	var schoolLevelValue_count=$("#schoolLevelValue option").length;
	var graduateYear_count=$("#schoolLevelValue option").length;
	  for(var i=0;i<schoolLevelValue_count;i++){ 
		  if($("#schoolLevelValue ").get(0).options[i].value == schoolLevelValue){  
	            $("#schoolLevelValue ").get(0).options[i].selected = true;  
	            break;  
	        }  
	    } 
	  
	  for(var i=0;i<graduateYear_count;i++){ 
		  if($("#graduateYear ").get(0).options[i].text == graduateYear){  
	            $("#graduateYear ").get(0).options[i].selected = true;  
	            break;  
	        }  
	    }
	  showNum(graduateYear);
	});

	function showNum(gy) {
		if (gy != -1) {
			var schoolLevelValue = $("#schoolLevelValue").val();
			var graduateYear = $("#graduateYear").val();
			$.post("${ctx}/admin/exam-param/student/studentcount.json", {
				graduateYear : graduateYear,
				schoolLevelValue : schoolLevelValue
			}, function(result) {
				$("#num").html("共" + result + "人");
			});
		}
	}

	function selectGY(level) {
		if (level != -1) {
			$('#graduateYear').empty();
			$.post('${ctx}/admin/exam-param/student/selectgraduateyear.json', {
				level : level
			}, function(res) {
				var first = $('<option value="-1">请选择</option>');
				$('#graduateYear').append(first);
				$.each(res,
						function(n, obj) {
							var opt = $('<option value="'+obj+'">' + obj
									+ '</option>');
							$('#graduateYear').append(opt);
						});
			});
		}
	}
</script>
</html>