[함수] DB연동 무한 다중 셀렉트 > MySQL Tip

본문 바로가기
 

[함수] DB연동 무한 다중 셀렉트

페이지 정보

작성자 no_profile 차동박 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 댓글 0건 조회 22,470회 작성일 08-07-08 22:16

본문

아래 거친마루님 께서 올리신 다중셀렉트에 비하면 허접입니다.
거친마루님께서 말씀하신대로 내용이 많은 Array형태의 무한다중셀렉트 입니다.
여기서 중요한것이 바로 무한 -_-; 한칸.두칸..세칸..짜리 셀렉트가 아닌 ...
붙이려면 계속 10칸 20칸도 가능합니다. 단, 내용이 많지 않을경우만요.....

<?
include " DB 연결 정보 ";
?>
<script>
<!--
var arrItems1 = new Array();
var arrItemsGrp1 = new Array();


<?php
$result=mysql_query("SELECT * FROM bigcate");
$i=1;
while($rows=mysql_fetch_array($result)){
$cont="$rows[bcate_name]";
printf("arrItems1[$i] = \"$cont\"; \n");
printf("arrItemsGrp1[$i] = $rows[bcate_id]; \n");
$i++;
}
?>

var arrItems2 = new Array();
var arrItemsGrp2 = new Array();

<?php
$result1=mysql_query("SELECT * FROM smallcate");
$i=1;
while($rows1=mysql_fetch_array($result1)){
$cont1="$rows1[scate_name]";
printf("arrItems2[$i] = \"$cont1\"; \n");
printf("arrItemsGrp2[$i] = $rows1[cid]; \n");
$i++;
}
?>

var arrItems3 = new Array();
var arrItemsGrp3 = new Array();

<?php
$result3=mysql_query("SELECT * FROM testcate");
$i=1;
while($rows3=mysql_fetch_array($result3)){
$cont3="$rows3[scate_name]";
printf("arrItems3[$i] = \"$cont3\"; \n");
printf("arrItemsGrp3[$i] = $rows3[cid]; \n");
$i++;
}
?>

function selectChange(control, controlToPopulate, ItemArray, GroupArray)
{
var myEle ;
var x ;
for (var q=controlToPopulate.options.length;q>=0;q--) controlToPopulate.options[q]=null;
if (control.name == "firstChoice") {
for (var q=myChoices.thirdChoice.options.length;q>=0;q--) myChoices.thirdChoice.options[q] = null;
}
myEle = document.createElement("option") ;
myEle.value = 0 ;
myEle.text = "[항목을 선택 하세요]" ;
controlToPopulate.add(myEle) ;
for ( x = 0 ; x < ItemArray.length ; x++ )
{
if ( GroupArray[x] == control.value )
{
myEle = document.createElement("option") ;
myEle.value = x ;
myEle.text = ItemArray[x] ;
controlToPopulate.add(myEle) ;
}
}
}
//-->
</script>

<form name='form' method='post' action='pds_upost.php' enctype='multipart/form-data'>
<SELECT id=aid name=acate onchange="selectChange(this, form.bid, arrItems1, arrItemsGrp1);">
<option value=0 SELECTED>[항목을 선택하세요]</option>
<option value=1 SELECTED>[자료실1]</option>
<option value=2 SELECTED>[자료실2]</option>
</select>

</SELECT>
<SELECT id=bid name=bcate onchange="selectChange(this, form.sid, arrItems2, arrItemsGrp2);"></SELECT>

<SELECT id=sid name=scate onchange="selectChange(this, form.cid, arrItems3, arrItemsGrp3);"></SELECT>

<SELECT id=cid name=ccate></SELECT>
</form>

댓글목록

등록된 댓글이 없습니다.

Total 243건 3 페이지
MySQL Tip 목록
번호 제목 글쓴이 조회 날짜
207 no_profile 차동박 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 24748 10-29
206 no_profile 차동박 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 34845 10-29
205 no_profile 차동박 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 22303 10-29
204 no_profile 차동박 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 13204 10-28
203 no_profile 차동박 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 19668 10-27
202 no_profile 차동박 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 21783 10-22
201 no_profile 차동박 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 13136 09-12
200 no_profile 차동박 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 14249 09-11
열람중 no_profile 차동박 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 22471 07-08
198 no_profile 차동박 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 20951 07-08
197 no_profile 차동박 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 19277 04-14
196 no_profile 차동박 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 12568 04-14
195 no_profile 차동박 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 12588 04-01
194 no_profile 차동박 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 13281 01-05
193 no_profile 차동박 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 20994 01-01
192 no_profile 차동박 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 12619 12-18
191 no_profile 차동박 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 20220 11-06
190 no_profile human 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 28327 09-11
게시물 검색