Open eunja511005 opened 1 year ago
화면 로딩시 셀렉트 박스 CommonCode 테이블에서 공통으로 가져 올 수 있도록 구현
<select class="form-select" id="modalVisibility" name="openTarget" required></select> <select class="form-select" id="modalPostType" name="postType" required></select>
populateSelectBox('modalVisibility', '/commonCode/VISIBILITY'); populateSelectBox('modalPostType', '/commonCode/POSTTYPE');
function populateSelectBox(selectBoxId, url) { var selectBox = $('#' + selectBoxId); selectBox.empty(); selectBox.append($('<option>').val('').text('ALL')); $.ajax({ url: url, success: function(response) { if (response.success) { $.each(response.data, function(index, commonCode) { selectBox.append($('<option>').val(commonCode.code).text(commonCode.value)); }); } else { swal({ title: "Application Error", text: response.errorMessage, icon: "warning", button: "OK", }) } }, error: function() { swal({ title: "Ajax Error", text: "Failed to get the common code data.", icon: "warning", button: "OK", }) }, }); }
화면 로딩시 셀렉트 박스 CommonCode 테이블에서 공통으로 가져 올 수 있도록 구현