다중 셀렉트 구현하기 (자바스크립트활용) > PHP

STUDY ROOM

PHP

다중 셀렉트 구현하기 (자바스크립트활용)

페이지 정보

작성자 JMStudy 작성일07-01-08 21:14 조회8,771회 댓글0건

본문

########## test.php ##########







<?
$res = mysql_query("select * from table");
while($row = mysql_fetch_array($res)){
?>
<?=$row[name]?>
<?}?>









########## loadpage.php ##########

$res = mysql_query("select * from table where test_time='$trigger'");
$total = mysql_num_rows($res);
$total = $total+1;

header("Content-Type: application/x-javascript");

echo "document.forms['$form'].elements['$target'].length = $total; \n";//$total은 추가할 옵션의 수

if($trigger == ""){ //1번 select 박스가 초기값(선택)일시 2번 select 초기화.
echo "document.forms['$form'].elements['test_date'].length =1; \n";
echo "document.forms['$form'].elements['test_date'].options[0].text = ':: 나 선택하세요 ::'; \n";
}

$i=0; //옵션 수의 초기화
while($row = mysql_fetch_array($res)){
echo "document.forms['$form'].elements['$target'].options[$i].text = '$row[name]'; \n";
echo "document.forms['$form'].elements['$target'].options[$i].value = '$row[idroom]'; \n";
$i++; // 실행시 1씩 증가
}
댓글목록

등록된 댓글이 없습니다.