메뉴 건너뛰기

?

단축키

Prev이전 문서

Next다음 문서

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

단축키

Prev이전 문서

Next다음 문서

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

조회 페이지에서 검색 조건을 넣고 검색을 하게 되면 결과 값이 보입니다.


하지만 검색했던 검색 조건들은 초기화가 되어 검색했던 조건을 확인하기 어렵습니다.


그래서 결과가 나온 후 값들을 jquery 에서 넣어주거나 선택할 경우가 발생합니다.


아래 소스는 그러한 경우 처리 하는 방법입니다.


jquery에서 라디오(radio) 버튼을 값으로 선택, 셀렉트(select) 박스를 값으로 선택하는 방법입니다.


그리고 라디오(radio) 버튼 선택으로 인한 이벤트 처리입니다


<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() {
                 
                //검색하고 나서 결과를 보여줄때 검색 조건을 그대로 노출
                //if("${serviceType}" == "sports"){ //serviceType 이 sport 일 경우 셋팅
                if("sports" == "sports"){
                 
                    //라디오 버튼 값으로 선택
                    $('input:radio[name="serviceType"][value="sports"]').prop('checked', true);
                    //셀렉트 박스 값으로 선택
                    $("select[name='sportsMainCategory']").val("2").attr("selected", "selected");
                    //공연/전시 카테고리 hide
                    $( "#viewConcertCategory" ).hide();
                    //스포츠 카테고리 show
                    $( "#viewSportCategory" ).show();
                    //스포츠 일때 담당MD 비활성화
                    $( "#mdName" ).prop( "disabled", true );
                    //담당MD 입력값 초기화;
                    $( "#mdName" ).val("");
                }
                 
                //라디오 버튼 변경시 이벤트
                $("input[name='serviceType']:radio").change(function () {
                        //라디오 버튼 값을 가져온다.
                        var serviceType = this.value;
                                         
                        if(serviceType == "sports"){//스포츠인 경우
                            //스포츠 일때 공연/전시 카테고리 hide
                            $( "#viewConcertCategory" ).hide();
                            //스포츠 일때 스포츠 카테고리 show
                            $( "#viewSportCategory" ).show();
                            //스포츠 일때 담당MD 비활성화
                            $( "#mdName" ).prop( "disabled", true );
                            $( "#mdName" ).val("");
                        }else if(serviceType == "concert"){//공연/전시인 경우
                            //공연/전시 일때 공연/전시 카테고리 show
                            $( "#viewConcertCategory" ).show();
                            //공연/전시 일때 스포츠 카테고리 show
                            $( "#viewSportCategory" ).hide();
                            //공연/전시 일때 담당 MD 활성화
                            $( "#mdName" ).prop( "disabled", false );
                        }
                                         
                    });
            });
        </script>
    </head>
    <body>
        <input type="radio" name="serviceType" value="concert" checked><span> 공연/전시</span>
        <input type="radio" name="serviceType" value="sports"><span> 스포츠</span>
        <br>
        <br>
        <span id="viewConcertCategory">
            공연/전시 카테고리: 
            <select class="form-control concertMainCategory" name="concertMainCategory" style="width:200px">
                <option value="">전체</option>
                <option value="1">뮤지컬</option>
                <option value="2">콘서트</option>
            </select>
        </span>
        <span id="viewSportCategory" style="display:none">
            스포츠 카테고리: 
            <select class="form-control sportsMainCategory" name="sportsMainCategory" style="width:200px">
                <option value="">전체</option>
                <option value="1">야구</option>
                <option value="2">농구</option>
                <option value="3">축구</option>
            </select>
        </span>
        <br>
        <br>
        담당MD <input type="text" class="form-control" id="mdName" name="mdName" value="husk"/>
    </body>
</html>


  1. jquery 팝업 차단 없이 띄우기

    Date2019.03.05 Views2863
    Read More
  2. [jQuery] 라디오(radio) 버튼, 체크박스(checkbox) 선택/해제 하는 방법

    Date2019.03.05 Views1129
    Read More
  3. jQuery 기초 (Query link url / download (위치, 사용법) // p태그, id, class 접근 / 일반태그 가져오기 / 클릭시 값)

    Date2019.01.16 Views1079
    Read More
  4. jQuery 기초 (클릭하면 이미지 변경 / mouseover시 애니메이션 효과주기 / 동적으로 변경)

    Date2019.01.16 Views1506
    Read More
  5. jQuery 기초 (focus, blur, toggle / mouseenter, mouseleave, mousedown, mouseup, hover)

    Date2019.01.16 Views1261
    Read More
  6. jQuery 기초 (style.css <link> 로 추가하기 / 버튼 클릭시 데이터 삽입)

    Date2019.01.16 Views1181
    Read More
  7. jQuery 기초 (JQuery - text(), val(), html(), attr(), prop())

    Date2019.01.16 Views1055
    Read More
  8. jQuery 기초 (attr()로 두가지 동시에 접근 / 변경)

    Date2019.01.16 Views1119
    Read More
  9. jQuery 기초 (텍스트 추가 (createElement, createTextNode, appendChild), (html, javascript, jquery)

    Date2019.01.16 Views1411
    Read More
  10. jQuery 기초 ((문자열 추가 .before / .after) (문자열 삭제 .remove / .empty)

    Date2019.01.16 Views1084
    Read More
  11. jQuery 기초 (txt 파일 가져오기 (load) , 클릭시에 배경색을 변경(json))

    Date2019.01.16 Views3225
    Read More
  12. Query 기초 (동적 테이블 (데이터 추가 / 삭제), integrateTable(정렬(sort))

    Date2019.01.16 Views2192
    Read More
  13. jQuery 기초 (jQuery 달력 (datepicker))

    Date2019.01.16 Views1321
    Read More
  14. jQuery 기초 (Postcodify - 도로명주소 우편번호 검색 프로그램 (코딩 예제) (HTML) / POP UP 버젼)

    Date2019.01.16 Views1349
    Read More
  15. .removeAttr() : 특정 속성을 제거

    Date2019.01.16 Views1021
    Read More
  16. .attr() : 태그의 속성 값을 읽어오거나 속성을 추가및 재설정

    Date2019.01.16 Views962
    Read More
  17. popModal jQuery Plugin Examples / 무료 jQuery 팝업 플러그인

    Date2019.01.16 Views1234
    Read More
  18. jQuery Plugin : Slider

    Date2019.01.10 Views1113
    Read More
  19. jQuery datepicker 팝업창 사이즈 바꾸기

    Date2019.01.10 Views1499
    Read More
  20. jQuery를 이용한 스크롤 따라니는 배너를 쉽게 맨들기(scroll follow)

    Date2019.01.10 Views1093
    Read More
Board Pagination Prev 1 2 3 4 5 6 7 8 9 Next
/ 9

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

© k2s0o1d4e0s2i1g5n. All Rights Reserved