편집을 취소할 수 있습니다. 이 편집을 되돌리려면 아래의 바뀐 내용을 확인한 후 게시해주세요.
최신판 | 당신의 편집 | ||
8번째 줄: | 8번째 줄: | ||
==자바스크립트== | ==자바스크립트== | ||
{{참고|자바스크립트 라디오 버튼}} | {{참고|자바스크립트 라디오 버튼}} | ||
< | <source lang='html5'> | ||
<tr> | |||
<td> | |||
<label>국가</label> | |||
</td> | |||
<td> | |||
<label><input type='radio' name='fruit' value='apple' />사과</label> | <label><input type='radio' name='fruit' value='apple' />사과</label> | ||
<label><input type='radio' name='fruit' value='banana' />바나나</label> | <label><input type='radio' name='fruit' value='banana' />바나나</label> | ||
<label><input type='radio' name='fruit' value='lemon' checked='checked' />레몬</label> | <label><input type='radio' name='fruit' value='lemon' checked='checked' />레몬</label> | ||
< | </td> | ||
<script> | <script> | ||
25번째 줄: | 30번째 줄: | ||
} | } | ||
} | } | ||
alert( '선택된 항목 인덱스: '+checked_index+'\n선택된 항목 값: '+checked_value ); | |||
} | } | ||
</script> | </script> | ||
</ | </source> | ||
<jsfiddle>er8ne8yw</jsfiddle> | |||
==jQuery== | ==jQuery== | ||
{{참고|jQuery 라디오 버튼}} | {{참고|jQuery 라디오 버튼}} | ||
< | <source lang='html5'> | ||
<script src="//code.jquery.com/jquery.min.js"></script> | <script src="//code.jquery.com/jquery.min.js"></script> | ||
<script> | <script> | ||
$(function() { | $(function() { | ||
$("#btn-show-checked").click(function() { | $("#btn-show-checked").click(function() { | ||
alert( $("input[name=fruit]:checked").val() ); | |||
}); | }); | ||
}); | }); | ||
46번째 줄: | 52번째 줄: | ||
<label><input type='radio' name='fruit' value='lemon' />레몬</label> | <label><input type='radio' name='fruit' value='lemon' />레몬</label> | ||
<button id='btn-show-checked'>선택된 항목 확인</button> | <button id='btn-show-checked'>선택된 항목 확인</button> | ||
</ | </source> | ||
<jsfiddle>vLyjbk0y</jsfiddle> | |||
==PHP== | ==PHP== | ||
;radio_button.php | ;radio_button.php | ||
< | <source lang='html5'> | ||
<!DOCTYPE html> | <!DOCTYPE html> | ||
<meta charset="utf-8" /> | <meta charset="utf-8" /> | ||
60번째 줄: | 67번째 줄: | ||
<input type='submit' value='제출' /> | <input type='submit' value='제출' /> | ||
</form> | </form> | ||
</ | </source> | ||
;radio_button_ok.php | ;radio_button_ok.php | ||
< | <source lang='php'> | ||
<?php | <?php | ||
echo '<xmp>'; | echo '<xmp>'; | ||
69번째 줄: | 76번째 줄: | ||
echo '</xmp>'; | echo '</xmp>'; | ||
?> | ?> | ||
</ | </source> | ||
;실행결과 | ;실행결과 | ||
*예제: http://zetawiki.com/ex/php/radio_button.php | |||
*바나나를 선택하고 [제출] 누른 경우 | *바나나를 선택하고 [제출] 누른 경우 | ||
< | <source lang='text'> | ||
Array | Array | ||
( | ( | ||
[fruit] => banana | [fruit] => banana | ||
) | ) | ||
</ | </source> | ||
==같이 보기== | ==같이 보기== |