editPopupNew.jsp 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
  2. <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
  3. <!--contents-->
  4. <section class="sub-container">
  5. <article class="menu-history">
  6. <ul>
  7. <li><a href="/admin/noticeList.do" class="home">홈</a></li>
  8. <li><a href="/admin/editPopup.do">팝업관리</a></li>
  9. </ul>
  10. </article>
  11. <article class="contents-wrap">
  12. <div class="title-box">
  13. <h2 class="h2-title">팝업관리</h2>
  14. <p class="title-info">평택시 교통정보센터 <span>관리자</span></p>
  15. </div>
  16. <!--탭버튼-->
  17. <div class="tab-btn">
  18. <p><a href="/admin/noticeList.do">공지사항</a></p>
  19. <p><a href="/admin/popupList.do" class="active">팝업창 관리</a></p>
  20. <p><a href="/admin/modiAdmin.do">관리자 정보변경</a></p>
  21. <p><a href="/admin/status.do">접속통계</a></p>
  22. <p><a href="/admin/logout.do">로그아웃</a></p>
  23. </div>
  24. <!--//탭버튼-->
  25. <form name="popForm" id="popForm" method="post" enctype="multipart/form-data">
  26. <input type="hidden" name="id" id="id" value="${popup.popupId }"/>
  27. <div class='board-write-form'>
  28. <dl>
  29. <dt>제목</dt>
  30. <dd><input
  31. type="text"
  32. id="title"
  33. name="title"
  34. class="form"
  35. style="width: 96%;"
  36. placeholder="제목을 입력하세요"
  37. value="${popup.title}"/></dd>
  38. <%-- <dd><input type="text" name="" placeholder="제목을 입력하세요." value="" style="width: 96%;" /></dd>--%>
  39. </dl>
  40. <dl>
  41. <dt>링크(url)</dt>
  42. <dd>
  43. <input
  44. type="text"
  45. id="url"
  46. name="url"
  47. class="form"
  48. style="width: 96%;"
  49. placeholder="http://는 생략"
  50. value="${popup.url}"/>
  51. <%-- <input type="text" name="" value="" style="width: 96%;" />--%>
  52. </dd>
  53. </dl>
  54. <dl>
  55. <dt>기간</dt>
  56. <dd>
  57. <input
  58. type="text"
  59. name="postFrom"
  60. id="postFrom"
  61. class="form"
  62. style="width:40%;"
  63. value="${popup.post_from}"/>
  64. ~
  65. <input
  66. type="text"
  67. name="postTo"
  68. id="postTo"
  69. class="form"
  70. style="width:40%;"
  71. value="${popup.post_to}"/>
  72. <%-- <input type="text" name="" value="" style="width:40%;"/> ~ <input type="text" name="" value="" style="width:40%;"/>--%>
  73. </dd>
  74. </dl>
  75. <dl>
  76. <dt>이미지</dt>
  77. <dd style="display:flex; align-items: center;">
  78. <div class="img-name" title="${popup.img_name}">${popup.img_name}</div>
  79. <input type="text" id="img_name" name="img_name" style="display:none" value="${popup.img_name}"/>
  80. <div class='file-btn' title="팝업이미지 파일 선택">파일 선택</div>
  81. <input
  82. type="file"
  83. style='border:none;display:none;'
  84. name="popupImg"
  85. id="popupImg"
  86. title="팝업이미지 파일 선택"
  87. accept="image/*"
  88. />
  89. </dd>
  90. <%-- <dd><input type="file" name="" placeholder="" value="" style='border:none' /></dd>--%>
  91. </dl>
  92. </div>
  93. </form>
  94. <div class='board-form-btn'>
  95. <input id="popupUpdate" type="button" name="" class='send' value="팝업수정등록" onclick="" />
  96. </div>
  97. </article>
  98. </section>
  99. <!--//contents-->
  100. <script type="text/javascript">
  101. $('.file-btn').on('click', function(){
  102. $('#popupImg').click();
  103. })
  104. $('#popupImg').on('change', function(){
  105. $('.img-name').text(this.files[0].name);
  106. $('#img_name').val(this.files[0].name);
  107. })
  108. $("#postFrom").datepicker({
  109. dateFormat: 'yy-mm-dd',
  110. prevText: '이전 달',
  111. nextText: '다음 달',
  112. monthNames: [
  113. '1월',
  114. '2월',
  115. '3월',
  116. '4월',
  117. '5월',
  118. '6월',
  119. '7월',
  120. '8월',
  121. '9월',
  122. '10월',
  123. '11월',
  124. '12월'
  125. ],
  126. monthNamesShort: [
  127. '1월',
  128. '2월',
  129. '3월',
  130. '4월',
  131. '5월',
  132. '6월',
  133. '7월',
  134. '8월',
  135. '9월',
  136. '10월',
  137. '11월',
  138. '12월'
  139. ],
  140. dayNames: [
  141. '일',
  142. '월',
  143. '화',
  144. '수',
  145. '목',
  146. '금',
  147. '토'
  148. ],
  149. dayNamesShort: [
  150. '일',
  151. '월',
  152. '화',
  153. '수',
  154. '목',
  155. '금',
  156. '토'
  157. ],
  158. dayNamesMin: [
  159. '일',
  160. '월',
  161. '화',
  162. '수',
  163. '목',
  164. '금',
  165. '토'
  166. ],
  167. showMonthAfterYear: true,
  168. yearSuffix: '년'
  169. });
  170. $("#postTo").datepicker({
  171. dateFormat: 'yy-mm-dd',
  172. prevText: '이전 달',
  173. nextText: '다음 달',
  174. monthNames: [
  175. '1월',
  176. '2월',
  177. '3월',
  178. '4월',
  179. '5월',
  180. '6월',
  181. '7월',
  182. '8월',
  183. '9월',
  184. '10월',
  185. '11월',
  186. '12월'
  187. ],
  188. monthNamesShort: [
  189. '1월',
  190. '2월',
  191. '3월',
  192. '4월',
  193. '5월',
  194. '6월',
  195. '7월',
  196. '8월',
  197. '9월',
  198. '10월',
  199. '11월',
  200. '12월'
  201. ],
  202. dayNames: [
  203. '일',
  204. '월',
  205. '화',
  206. '수',
  207. '목',
  208. '금',
  209. '토'
  210. ],
  211. dayNamesShort: [
  212. '일',
  213. '월',
  214. '화',
  215. '수',
  216. '목',
  217. '금',
  218. '토'
  219. ],
  220. dayNamesMin: [
  221. '일',
  222. '월',
  223. '화',
  224. '수',
  225. '목',
  226. '금',
  227. '토'
  228. ],
  229. showMonthAfterYear: true,
  230. yearSuffix: '년'
  231. });
  232. $("#popupUpdate").click(function () {
  233. const from = $("#postFrom");
  234. const to = $("#postTo");
  235. const title = $("#title");
  236. const image = $('#img_name');
  237. const dateType = RegExp(/^\d{4}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$/);
  238. if (title.val() == "") {
  239. alert("팝업제목은 필수 입니다.");
  240. title.focus();
  241. return false;
  242. }
  243. if (from.val() == "") {
  244. alert("팝업기간은 필수 입니다.");
  245. from.focus();
  246. return false;
  247. }
  248. if (to.val() == "") {
  249. alert("팝업기간은 필수 입니다.");
  250. to.focus()
  251. return false;
  252. }
  253. if (!dateType.test(from.val())) {
  254. alert("날짜가 올바르지 않습니다.");
  255. from.focus();
  256. return false;
  257. }
  258. if (!dateType.test(to.val())) {
  259. alert("날짜가 올바르지 않습니다.");
  260. to.focus();
  261. return false;
  262. }
  263. if (from.val() > to.val()) {
  264. alert("시작일자가 종료일자보다 큽니다.");
  265. to.focus();
  266. return false;
  267. }
  268. if (image.val() == "") {
  269. alert("팝업이미지는 필수 입니다.");
  270. return false;
  271. }
  272. if (image[0].files && image[0].files[0].size > 200000000) {
  273. alert("팝업이미지 첨부 파일 사이즈는 190MB 이내로 등록 가능합니다.");
  274. return false;
  275. }
  276. $("#popForm").attr("action", "/admin/updatePopup.do");
  277. $("#popForm").submit();
  278. });
  279. </script>