1. 달력이 있다는 가정 하에 달력에서 날짜를 클릭하면 그 날짜에 해당하는 date를 value로 지정하고 싶다.
main.html
<div onclick="modalOn('{{ date }}')">
클릭하면 모달창이 뜬다.
</div>
<!-- 여기서 date는 BE에서 가공한 '2022-01-01'형식의 날짜이다. -->
modal.html
<label class="modal_label">내가 클릭한 날짜:
<input type="date" id="date_label">
</label>
2. 클릭했을 경우 함수가 동작하도록 설정
main.js
function modalOn(date){
modal.style.display = "flex"
document.getElementById("date_label").value = date
}
id가 date_label의 value를 date로 한다.끝.
'WebDev' 카테고리의 다른 글
| SMOPS 팀 프로젝트 - 1 (0) | 2022.07.01 |
|---|---|
| WIL - 2022/06/19 (0) | 2022.06.19 |
| WIL - 2022/06/12 (0) | 2022.06.12 |
| OOP == Object Oriented Programming (0) | 2022.06.07 |
| 간단한 카카오 우편번호 서비스 따라하기 (0) | 2022.06.04 |