메뉴 건너뛰기

?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

라디오버튼, 체크박스, 셀렉트박스 값 선택하기 및 선택한 값을 가져오는 소스 입니다.


아래 예제 및 소스를 확인해 주시기 바랍니다. (결과확인 버튼 눌러보세요.)


============================================================



Test 책 종류: 소설 잡지 만화

할인 여부: 할인

결제수단:


============================================================


<html>
    <head>
        <title>Test</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <script type="text/javascript" src="http://code.jquery.com/jquery.js"></script>
        <script type="text/javascript">
            $(document).ready(function() {
                 
                //초기화
                //라디오버튼
                $("input:radio[name='book_type'][value='magazine']").prop('checked', true);
                //체크박스
                $("input:checkbox[name='sale_yn']").prop("checked", true);
                //셀렉트박스
                $("select[name='payment_type']").val("card").attr("selected", "selected");
                 
                //결과확인
                $("#check").click(function(){
             
                    alert("책 종류: "+$("input:radio[name='book_type']:checked").val());
                    alert("할인 여부: "+$("input[name='sale_yn']").is(":checked"));
                    alert("결제수단: "+$("select[name='payment_type'] option:selected").val());
                     
                });
                 
            });
        </script>
    </head>
    <body>
        책 종류: 
        <input type="radio" name="book_type" value="novel"><span> 소설</span>
        <input type="radio" name="book_type" value="magazine"><span> 잡지</span>
        <input type="radio" name="book_type" value="comic"><span> 만화</span>
        <br>
        <br>
        할인 여부: 
        <input type="checkbox" name="sale_yn"> 할인
        <br>
        <br>
        결제수단: 
        <select name="payment_type">
            <option value="cash">현금</option>
            <option value="card">카드</option>
            <option value="point">포인트</option>
        </select>
        <br>
        <br>
        <button id="check">결과확인</button>
    </body>
</html>


List of Articles
번호 제목 날짜 조회 수
119 검토하기: jQuery를 이용하여 form 처리하기 2017.03.02 7524
118 jquery 이용한 필수입력체크(input form) 2017.03.02 10561
117 jQuery 실행패턴 2017.03.02 6772
116 jQuery 입문: form 데이터 유효성 검사 2017.03.02 11800
115 예제로 만나보는 제이쿼리 - 비동기 파일업로드 file 2017.03.06 7345
114 파일 업로드 방법, 이미지 파일 업로드 예제 소스 2017.03.06 9032
113 Ajax 파일 업로드 샘플 코드 2017.03.11 7793
112 jquery를 활용한 입력폼 초기화하기 2017.03.27 8705
111 jquery css div, li 리스트 선택한 메뉴 변경 출처: http://okkks.tistory.com/1062 [이건없지] file 2017.07.05 5812
110 jquery 체크박스 배열 처리. 변수 하나에 담기. 2018.07.04 4669
109 jQuery 유효성 검사 2018.07.04 3365
108 jQuery selectBox 컨트롤. 2018.07.25 2562
107 jquery - select option 선택값 가져오기 2018.09.06 5334
106 jQuery 폼 입력값 체크 예제 2018.09.06 2103
105 입력폼에 입력되는 값의 유효성 체크하기 두번째 file 2018.09.06 1836
104 페이지 이동 제어 - href, replace, pushState() 2018.09.06 2628
103 외부 파일 드래그 드롭 구현 file 2018.09.06 1687
102 드래그 & 드랍 구현 - on()[이벤트리스너] file 2018.09.06 2899
101 [jQuery] 확인 창(confirm), 페이지 이동(location.replace) 2018.09.06 2655
100 [jQuery] input 박스에 maxlength 만큼 입력했을 때 자동으로 다음 박스로 이동하기 2018.09.06 1837
Board Pagination Prev 1 2 3 4 5 6 7 8 9 Next
/ 9

하단 정보를 입력할 수 있습니다

© k2s0o1d4e0s2i1g5n. All Rights Reserved