728x90
반응형
Select
HTML
<select id="receipt" name="receipt">
<option value='one'>영수증 1</option>
<option value='two'>영수증 2</option>
<option value='three'>영수증 3</option>
</select>
Javascript
* id 값으로 가져오기
let receipt_type = document.querySelector('select#receipt option:checked').value;
* name 값으로 가져오기
let receipt_type = document.querySelector('select[name="receipt"] option:checked').value;
Radio
HTML
<input type="radio" name="payment" value="one">
<input type="radio" name="payment" value="two">
Javascript
let pay_method = document.querySelector('input[type="radio"][name="payment"]:checked').value;
Checkbox
HTML
<div>
<input type="checkbox" name="work_type" value="Part_Time" >Part Time</label>
<input type="checkbox" name="work_type" value="Full_Time" >Full Time</label>
</div>
Javascript
const checked_list = document.querySelectorAll("input[type='checkbox']:checked");
728x90
반응형
'Javascript' 카테고리의 다른 글
Javascript: Animation 백그라운드 동작 중지 # requestAnimationFrame (0) | 2023.09.11 |
---|---|
Javascript: slide # 무한 슬라이드 (0) | 2023.09.10 |
Javascript: new Date # 날짜 (0) | 2023.03.27 |
javascript: event.target vs event.currentTarget (0) | 2023.03.09 |
주소 API # 행정안전부 # javascript # ajax # xml (0) | 2023.03.08 |