Global It Leader!!



 
 

Javasript 제이쿼리 load() 로 2중 셀렉트박스(select box) 구현하기

페이지 정보

작성자 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 댓글 0건 조회 7,601회 작성일 12-04-24 15:51

본문

<div>
    <select name='sel_1'>
    <option value='1'>1번 업체</option>
    <option value='2'>2번 업체</option>
    <option value='3'>3번 업체</option>
    </select>
</div>
<div id="sel_2_section"></div>
<div id="hidden_section"></div>
 
<script type="text/javascript">
<!--
$(documnet).ready(function() {
    $("select[name='sel_1']").change(function() {
        var thisVal = $(this).val();
        $("#hidden_section").load("b.php", {
            "thisVal" : thisVal
        });
    });
});
//-->
</script>

b.php의 내용은 load를 이용하여 id="hidden_section"으로 불러와지는 php문서의 내용이다.

// b.php
$sql = "select * from tblName where compcode = '".$thisVal."'";
$result = sql_query($sql);
$selBox = "<select name='sel_2'><option value=''>¼±ÅÃÇϼ¼¿ä.</option>";
while($row = mysql_fetch_array($sql)) {
    $selBox .= "<option value='".$row['number']."'>".$row['name']."</option>";
}
$selBox .= "</select>";
 
echo <<<END
<script type="text/javascript" src="./js/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
<!--
$(document).ready(function() {
    $("#sel_2_section").html("$selBox");
    $("#sel_2_section").html("");
});
//-->
</script>
END;
?>


hidden_section에 php문서를 로드하고 쿼리로 데이터를 가져온후
while문을 사용하여 selBox의 html코드를 변수화한다.
그리고 jquery로 다시 본 페이지에서 html()로 만들어준다...

댓글목록

등록된 댓글이 없습니다.

전체 440
게시물 검색
컴퓨터언어 목록
번호 제목 글쓴이 조회 날짜
160 Javasript no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6420 09-17
159 PHP no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5532 09-14
158 Javasript no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5814 08-21
157 Javasript no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5966 08-21
156 PHP no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5022 08-17
155 Mysql no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5029 08-17
154 Mysql no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5857 08-16
153 Mysql no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4937 08-16
152 Mysql no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 11701 05-07
151 Mysql no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4815 08-10
150 Mysql no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6033 08-03
149 Mysql no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5156 08-03
148 Mysql no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5650 07-30
147 Mysql no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5001 07-27
146 Javasript no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6758 07-13
145 Javasript no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6332 06-13
144 PHP no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6094 06-08
143 Javasript no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5942 04-28
142 Javasript no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 8089 04-24
열람중 Javasript no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 7602 04-24