[php] 2단 셀렉트 연동
본문
<script language="javascript">
window.onload = function() {
document.getElementById("wr2_7").onchange = function() { getClass(this.form.wr2_7.options.selectedIndex) };
}
var classG = new Array(
new Array("##선택##")
<?php
$sql = " select *
from {$g5['menu_table']}
where me_use = '1'
and length(me_code) = '2'
order by me_order, me_id ";
$result = sql_query($sql, false);
for ($i=0; $row=sql_fetch_array($result); $i++) {
?>,new Array(
<?php
$sql2 = " select *
from {$g5['menu_table']}
where me_use = '1'
and length(me_code) = '4'
and substring(me_code, 1, 2) = '{$row['me_code']}'
order by me_order, me_id ";
$result2 = sql_query($sql2);
for ($k=0; $row2=sql_fetch_array($result2); $k++) {
if($k==0) {
?>
"<?php echo $row2[me_name]?>"
<?php } else { ?>
,"<?php echo $row2[me_name]?>"
<?php } ?>
<?php
}
?>)
<?php } ?>
);
var temp, i=0, j=0;
var cselect;
function getClass(item) {
temp = document.getElementById("wr2_8");
subCnt = temp.options.length;
for (i=(subCnt-1); i>0; i--) { temp.options[i] = null }
for (var j=0; j<classG[item].length; j++) {
cselect = classG[item][j];
temp.options[j] = new Option(cselect, cselect)
}
}
</script>
<select name="wr2[7]" id="wr2_7">
<option value="">선택해 주세요</option>
<?php
$sql = " select *
from {$g5['menu_table']}
where me_use = '1'
and length(me_code) = '2'
order by me_order, me_id ";
$result = sql_query($sql, false);
for ($i=0; $row=sql_fetch_array($result); $i++) {
?>
<option value="<?php echo $row['me_name'] ?>"><?php echo $row['me_name'] ?></option>
<?php } ?>
</select>
<select name="wr2[8]" id="wr2_8">
<option value="">선택해 주세요</option>
</select>
window.onload = function() {
document.getElementById("wr2_7").onchange = function() { getClass(this.form.wr2_7.options.selectedIndex) };
}
var classG = new Array(
new Array("##선택##")
<?php
$sql = " select *
from {$g5['menu_table']}
where me_use = '1'
and length(me_code) = '2'
order by me_order, me_id ";
$result = sql_query($sql, false);
for ($i=0; $row=sql_fetch_array($result); $i++) {
?>,new Array(
<?php
$sql2 = " select *
from {$g5['menu_table']}
where me_use = '1'
and length(me_code) = '4'
and substring(me_code, 1, 2) = '{$row['me_code']}'
order by me_order, me_id ";
$result2 = sql_query($sql2);
for ($k=0; $row2=sql_fetch_array($result2); $k++) {
if($k==0) {
?>
"<?php echo $row2[me_name]?>"
<?php } else { ?>
,"<?php echo $row2[me_name]?>"
<?php } ?>
<?php
}
?>)
<?php } ?>
);
var temp, i=0, j=0;
var cselect;
function getClass(item) {
temp = document.getElementById("wr2_8");
subCnt = temp.options.length;
for (i=(subCnt-1); i>0; i--) { temp.options[i] = null }
for (var j=0; j<classG[item].length; j++) {
cselect = classG[item][j];
temp.options[j] = new Option(cselect, cselect)
}
}
</script>
<select name="wr2[7]" id="wr2_7">
<option value="">선택해 주세요</option>
<?php
$sql = " select *
from {$g5['menu_table']}
where me_use = '1'
and length(me_code) = '2'
order by me_order, me_id ";
$result = sql_query($sql, false);
for ($i=0; $row=sql_fetch_array($result); $i++) {
?>
<option value="<?php echo $row['me_name'] ?>"><?php echo $row['me_name'] ?></option>
<?php } ?>
</select>
<select name="wr2[8]" id="wr2_8">
<option value="">선택해 주세요</option>
</select>
추천0
댓글목록 0
등록된 댓글이 없습니다.