ที่นี้เรามาดู Javascript กันครับ
<script language="Javascript">
function changeSelect2(obj){
var theform = obj.form;
theform.select2.length = 0;
switch(obj.value){
case "1":
{
theform.select2.options[0] = new Option('1.1','1.1');
theform.select2.options[1] = new Option('1.2','1.2');
theform.select2.options[2] = new Option('1.3','1.3');
theform.select2.options[3] = new Option('1.4','1.4');
theform.select2.disabled = false;
}
break;
case "2":
{
theform.select2.options[0] = new Option('2.1','2.1');
theform.select2.options[1] = new Option('2.2','2.2');
theform.select2.options[2] = new Option('2.3','2.3');
theform.select2.options[3] = new Option('2.4','2.4');
theform.select2.disabled = false;
}
break;
case "3":
{
theform.select2.options[0] = new Option('3.1','3.1');
theform.select2.options[1] = new Option('3.2','3.2');
theform.select2.options[2] = new Option('3.3','3.3');
theform.select2.options[3] = new Option('3.4','3.4');
theform.select2.disabled = false;
}
break;
}
}
</script>