728x90
레슨변경시 시간option 변경 골프선택시 15분, 25분 PT선택시 60분
처음 코드
function fn_LessonChange() {
var searchLessonMasterIdAdmin = document.querySelector('.searchLessonMasterIdAdmin');
var searchLessonTime = document.getElementById('searchLessonTime');
var selectedLesson = searchLessonMasterIdAdmin.value;
var selectedValue = document.querySelector(".searchLessonMasterIdAdmin").value;
if(selectedLesson == 'PT'){
$("#searchLessonTime").empty();
var option = document.createElement("option");
option.text = "60";
option.value = "60";
searchLessonTime.add(option);
}else if (selectedLesson == 'golf') {
$("#searchLessonTime").empty();
var option15 = document.createElement("option");
option15.text = "15";
option15.value = "15";
searchLessonTime.add(option15);
var option25 = document.createElement("option");
option25.text = "25";
option25.value = "25";
searchLessonTime.add(option25);
}
}
<select name="searchLessonMasterId" class="searchLessonMasterIdAdmin" onchange="fn_LessonChange()" title="레슨구분">
<option value="" >레슨구분</option>
<c:forEach var="master" items="${lessonMasterList}" varStatus="status">
<option value="${master.lesson_master_id }" <c:if test="${searchVO.searchLessonMasterId eq master.lesson_master_id }">selected</c:if>>${master.lesson_master_nm }</option>
</c:forEach>
</select>
<select name="searchLessonTime" id="searchLessonTime" title="레슨시간" style="margin-right:5px" onchange="fn_search();">
<c:forEach var="time" items="${lessonInfo.lesson_time_list}" varStatus="status">
<option value="${time }" <c:if test="${searchVO.searchLessonTime eq time}">selected</c:if>>${time }</option>
<option value="${time }" <c:if test="${searchVO.searchLessonTime eq time}">selected</c:if>>${time }</option>
</c:forEach>
</select>
jstl 로 줄인 코드
function fn_LessonChange() {
var searchLessonMasterIdAdmin = document.querySelector('.searchLessonMasterIdAdmin');
var searchLessonTime = document.getElementById('searchLessonTime');
var selectedLesson = searchLessonMasterIdAdmin.value;
var selectedValue = document.querySelector(".searchLessonMasterIdAdmin").value;
<c:forEach var="master" items="${lessonMasterList}" varStatus="status">
if("${master.lesson_master_id}" === selectedLesson){
$("#searchLessonTime").empty();
<c:forEach var="lesson_time" items="${master.lesson_time_list}" varStatus="status">
var option = document.createElement("option");
option.text = "${lesson_time}";
option.value = "${lesson_time}";
searchLessonTime.add(option);
</c:forEach>
}
</c:forEach>
}
728x90
'SpringBoot' 카테고리의 다른 글
[Spring Boot] select 검색조건유지 jstl (0) | 2023.11.06 |
---|---|
[Spring Boot] DAO 검색 (0) | 2023.11.06 |
jsp 스크립트 sec:authorize access (0) | 2023.11.02 |
[Spring Boot] jsp - controller - service - dao (0) | 2023.11.01 |
어노테이션 (0) | 2023.09.22 |