ลองทำการประยุกต์ตรง OnChange() ให้ทำการนำค่า ID ของแต่ล่ะตัวไปเก็บไว้ใน hidden ครับ
Date :
2010-11-05 06:40:08
By :
webmaster
No. 2
Guest
<script type="text/javascript">
<!--
function setOptions(chosen) {
var selbox = document.myform.tumbon_id;
selbox.options.length = 0;
if (chosen == "") {
selbox.options[selbox.options.length] = new Option('เลือกอำเภอ','');
}
if (chosen == 1) {
selbox.options[selbox.options.length] = new Option('เลือกตำบล','');
selbox.options[selbox.options.length] = new Option('ตำบล1','1');
selbox.options[selbox.options.length] = new Option('ตำบล2','2');
selbox.options[selbox.options.length] = new Option('ตำบล3','3');
}
if (chosen == 2) {
selbox.options[selbox.options.length] = new Option('เลือกตำบล','');
selbox.options[selbox.options.length] = new Option('ตำบล4','4');
selbox.options[selbox.options.length] = new Option('ตำบล5','5');
selbox.options[selbox.options.length] = new Option('ตำบล6','6');
selbox.options[selbox.options.length] = new Option('ตำบล7','7');
}
if (chosen == 3) {
selbox.options[selbox.options.length] = new Option('เลือกตำบล','');
selbox.options[selbox.options.length] = new Option('ตำบล8','8');
selbox.options[selbox.options.length] = new Option('ตำบล9','9');
selbox.options[selbox.options.length] = new Option('ตำบล10','10');
}
if (chosen == 4) {
selbox.options[selbox.options.length] = new Option('เลือกตำบล','');
selbox.options[selbox.options.length] = new Option('ตำบล11','11');
}
if (chosen == 5) {
selbox.options[selbox.options.length] = new Option('เลือกตำบล','');
selbox.options[selbox.options.length] = new Option('ตำบล12','12');
selbox.options[selbox.options.length] = new Option('ตำบล13','13');
selbox.options[selbox.options.length] = new Option('ตำบล14','14');
}
if (chosen == 6) {
selbox.options[selbox.options.length] = new Option('เลือกตำบล','');
selbox.options[selbox.options.length] = new Option('ตำบล15','15');
selbox.options[selbox.options.length] = new Option('ตำบล16','16');
selbox.options[selbox.options.length] = new Option('ตำบล17','17');
selbox.options[selbox.options.length] = new Option('ตำบล18','18');
selbox.options[selbox.options.length] = new Option('ตำบล19','19');
}
if (chosen == 7) {
selbox.options[selbox.options.length] = new Option('เลือกตำบล','');
selbox.options[selbox.options.length] = new Option('ตำบล20','20');
selbox.options[selbox.options.length] = new Option('ตำบล21','21');
selbox.options[selbox.options.length] = new Option('ตำบล22','22');
selbox.options[selbox.options.length] = new Option('ตำบล23','23');
selbox.options[selbox.options.length] = new Option('ตำบล24','24');
selbox.options[selbox.options.length] = new Option('ตำบล25','25');
selbox.options[selbox.options.length] = new Option('ตำบล26','26');
}
if (chosen == 8) {
selbox.options[selbox.options.length] = new Option('เลือกตำบล','');
selbox.options[selbox.options.length] = new Option('ตำบล27','27');
selbox.options[selbox.options.length] = new Option('ตำบล28','28');
selbox.options[selbox.options.length] = new Option('ตำบล29','29');
}
}//-->
</script>