웹프로그래밍

Global It Leader!!


jQuery


 
 

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

페이지 정보

작성자 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 댓글 0건 조회 4,838회 작성일 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()로 만들어준다...

댓글목록

등록된 댓글이 없습니다.

전체 142
게시물 검색
jQuery 목록
번호 제목 글쓴이 조회 날짜
62 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4038 11-29
61 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6592 09-17
60 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5459 08-21
59 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4828 08-21
58 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6396 07-13
57 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5956 06-13
56 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5285 04-28
55 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5464 04-24
열람중 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4839 04-24
53 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5743 04-24
52 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4791 04-24
51 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4377 04-20
50 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4004 04-19
49 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4365 04-19
48 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4011 04-17
47 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4327 04-11
46 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4386 04-01
45 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4552 04-01
44 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4256 03-31
43 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4321 03-22