EASY7
동적 select 본문
<script language="javascript"> function changeDeptList(){ var selectedSchoolId=document.getElementById("schoolName").selectedIndex ; var selectedSchoolName=document.getElementById("schoolName")[selectedSchoolId].value; var length = document.getElementById("departmentName").options.length; for (var index=0; index<length; index++){ document.getElementById("departmentName").remove(0); } var deptList=new Array(); <c:forEach var="x" items="${departmentList}"> if("${x.schoolName}"== selectedSchoolName){ <c:forEach var="y" items="${x.departmentNameList}"> deptList.push("${y}"); </c:forEach> } </c:forEach> var i=0; for(i=0; i<deptList.length; i++){ var departmentOption= new Option(deptList[i],deptList[i]); document.getElementById("departmentName").options.add(departmentOption); } } </script>
<select name="schoolName" id="schoolName" onchange="changeDeptList()" > <option value="0">단과대학을 고르세요</option> <c:forEach var ="x" items="${departmentList}" > <option value="${x.schoolName}"> ${x.schoolName} </option> </c:forEach>
</select>
'개발 공부 > JSP' 카테고리의 다른 글
jstl에서 List의 길이 구하기 (size, length) (0) | 2018.06.21 |
---|---|
이클립스 아파치 톰캣서버 연동하기 (0) | 2016.12.16 |
jsp 주석(annotation) (0) | 2016.12.10 |
jsp가 java파일과 class로 변한 것 확인하기 (0) | 2016.12.10 |
jsp 웹 브라우저에 실행해보기 (0) | 2016.12.10 |
Comments