|
|
|
listbox 2 ชั้นโดยรับค่าจาก onchange ยังไงดีครับ ผมจะทำ list box 2 ชั้น โดยเลือกจังหวัด |
|
|
|
|
|
|
|
ใช้ได้เลยครับ ขอบคุณมากเลย
เอาดัดแปลงหน่อยก็ใช้ได้แล้วครับ
Code (PHP)
<script language = "JavaScript">
//**** List area (Start) ***//
function ListArea(SelectValue)
{
frmMain.area.length = 0
var myOption = new Option('','')
//frmMain.area.options[frmMain.area.length]= myOption
<?
$groupArea=array(1,1,2,2,3,3); //แยกจังหวัดลงในเขตแต่ละเขต
$area=array("กทมเขต1","กทมเขต2","กระบี่เขต1","กระบี่เขต2","กาญเขต1","กาญเขต2");
for($i=0;$i<6;$i++){ //value area จะนับตาม $i
?>
x = "<?=$i;?>";
mySubList = new Array();
strGroup = "<?=$groupArea[$i];?>";
strValue = "<?=$i;?>";
strItem = "<?=$area[$i];?>";
mySubList[x,0] = strItem;
mySubList[x,1] = strGroup;
mySubList[x,2] = strValue;
if (mySubList[x,1] == SelectValue){
var myOption = new Option(mySubList[x,0], mySubList[x,2])
frmMain.area.options[frmMain.area.length]= myOption
}
<?
}
?>
}
//**** List area (End) ***//
</script>
<title>Untitled Document</title>
</head>
<body>
<form name="frmMain" action="test2.php" method="post">
province
<select id="province" name="province" onChange = "ListArea(this.value)">
<?
$province = array("ทั้งหมด","กรุงเทพ","กระบี่","กาญจนบุรี");
for($j=0;$j<4;$j++){
?>
<option value="<?=$j; ?>"><?=$province[$j];?></option>
<?
}
?>
</select>
area
<select id="area" name="area" style="width:120px" >
<option value="">ทั้งหมด</option>
</select>
<input type="submit" name="button" id="button" value="Submit" />
</form>
|
|
|
|
|
Date :
2009-02-09 18:38:45 |
By :
canvas |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script language=javascript>
var aa = new Array("state1","state2","state3");
state1 = new Array("city1","city2");
state2 = new Array("city21","city22","city23");
state3 = new Array("city31","city32","city33");
function changeval()
{
var val1 = document.sform.sel1.value;
var optionArray = eval(val1);
for(var df=0; df<optionArray.length; df++)
{
var ss = document.sform.sel2;
ss.options.length = 0;
for(var ff=0; ff<optionArray.length; ff++)
{
var val = optionArray[ff];
ss.options[ff] = new Option(val,val);
}
}
}
</script>
<form name=sform>
<select name=sel1 onchange=changeval()>
<script language=javascript>
for(var dd=0; dd<aa.length; dd++)
{
document.write("<option value=\""+aa[dd]+"\">"+aa[dd]+"</option>");
}
</script>
</select>
<select name=sel2>
</select>
</form>
|
|
|
|
|
Date :
2009-02-10 17:10:27 |
By :
karama |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แบบนี้ ff ใช้ไม่ได้อ่ะครับ
|
|
|
|
|
Date :
2011-08-17 11:30:27 |
By :
oasiis |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ใช่ๆ ใครพอรู้ วิธีเก็บค่า ทั้ง2 ช่องบ้าง ครับบบ
|
|
|
|
|
Date :
2016-10-10 12:04:07 |
By :
baby137 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|