대문: 두 판 사이의 차이
보이기
편집 요약 없음 |
편집 요약 없음 |
||
| 1번째 줄: | 1번째 줄: | ||
<html> | <html> | ||
<form id=" | <form id="autoRadioSearch" action="/wiki/index.php/Special:Search" method="get"> | ||
<div> | |||
<label><input type="radio" name="scope" value="all" checked> 전체</label> | |||
<div | <label><input type="radio" name="scope" value="site"> 유적</label> | ||
<label> | <label><input type="radio" name="scope" value="concept"> 개념</label> | ||
<label | |||
<label | |||
</div> | </div> | ||
<input type="search" name="search" id="q" placeholder="검색어 입력"> | |||
<input | |||
</form> | </form> | ||
<script> | <script> | ||
document.getElementById(' | const form = document.getElementById('autoRadioSearch'); | ||
const q = document.getElementById('q'); | |||
form.addEventListener('change', () => { | |||
if (!q.value.trim()) return; | |||
const scope = document.querySelector('input[name="scope"]:checked').value; | const scope = document.querySelector('input[name="scope"]:checked').value; | ||
if (scope === 'site') | let query = q.value; | ||
if (scope === 'site') query += ' incategory:유적'; | |||
if (scope === 'concept') query += ' incategory:개념'; | |||
q.value = query; | |||
}; | form.submit(); | ||
}); | |||
</script> | </script> | ||
</html> | </html> | ||


