// ส่วนของ script
<script type="text/javascript" language="Javascript">
$(document).ready(function(){
showHideOption();
$("[name=EqName]").change(function(){
showHideOption();
});
});
function showHideOption(){
var option_type = $("[name=EqName]").val();
if(option_type=="Atomic-Absorption-Spectrometer(AA)"){
$("#option").fadeIn();$("#option1").fadeOut();$("#option2").fadeOut();$("#option3").fadeOut();
$("#option4").fadeOut();$("#option5").fadeOut();$("#option6").fadeOut();$("#option7").fadeOut();
}
else if(option_type=="Hi-performance-liquid-chromatography(HPLC)"){
$("#option1").fadeIn();$("#option").fadeOut();$("#option2").fadeOut();$("#option3").fadeOut();
$("#option4").fadeOut();$("#option5").fadeOut();$("#option6").fadeOut();$("#option7").fadeOut();
}
else if(option_type=="Fourier-transform-infared-spectroscopy"){
$("#option2").fadeIn();$("#option").fadeOut();$("#option1").fadeOut();$("#option3").fadeOut();
$("#option4").fadeOut();$("#option5").fadeOut();$("#option6").fadeOut();$("#option7").fadeOut();
}
else if(option_type=="Ultraviolet-Visible-specttrophotometer"){
$("#option3").fadeIn();$("#option").fadeOut();$("#option1").fadeOut();$("#option2").fadeOut();
$("#option4").fadeOut();$("#option5").fadeOut();$("#option6").fadeOut();$("#option7").fadeOut();
}
else if(option_type=="Polymerase-chain-reaction"){
$("#option4").fadeIn();$("#option").fadeOut();$("#option1").fadeOut();$("#option2").fadeOut();
$("#option3").fadeOut();$("#option5").fadeOut();$("#option6").fadeOut();$("#option7").fadeOut();
}
else if(option_type=="Gel-Documentation"){
$("#option5").fadeIn();$("#option").fadeOut();$("#option1").fadeOut();$("#option2").fadeOut();
$("#option3").fadeOut();$("#option4").fadeOut();$("#option6").fadeOut();$("#option7").fadeOut();
}
else if(option_type=="น้ำกลั่นคุณภาพ-Water-Distiller"){
$("#option6").fadeIn();$("#option").fadeOut();$("#option1").fadeOut();$("#option2").fadeOut();
$("#option3").fadeOut();$("#option4").fadeOut();$("#option5").fadeOut();$("#option7").fadeOut();
}
else if(option_type=="Hot-air-oven"){
$("#option7").fadeIn();$("#option").fadeOut();$("#option1").fadeOut();$("#option2").fadeOut();
$("#option3").fadeOut();$("#option4").fadeOut();$("#option5").fadeOut();$("#option6").fadeOut();
}
else if(option_type=="Polymerase-chain-reaction1"){
$("#option4").fadeIn();$("#option").fadeOut();$("#option1").fadeOut();$("#option2").fadeOut();
$("#option3").fadeOut();$("#option7").fadeOut();$("#option5").fadeOut();$("#option6").fadeOut();
}
else if(option_type=="Polymerase-chain-reaction2"){
$("#option4").fadeIn();$("#option").fadeOut();$("#option1").fadeOut();$("#option2").fadeOut();
$("#option3").fadeOut();$("#option7").fadeOut();$("#option5").fadeOut();$("#option6").fadeOut();
}
else{
$("#option").fadeOut();
$("#option1").fadeOut();
$("#option2").fadeOut();
$("#option3").fadeOut();
$("#option4").fadeOut();$("#option5").fadeOut();$("#option6").fadeOut();$("#option7").fadeOut();
//$("[name=data1]").attr("disabled",true);
}
}
</script>
//ส่วนของ list ที่1
$sql1="SELECT EqName FROM equipment;";
$result1= mysql_query($sql1);
echo mysql_error();
echo "ชื่ออุปกรณ์";
echo "<select name='EqName' >";
echo "<option value='0'>-- ทุกประเภท --</option>";
while($dbdepart1=mysql_fetch_array($result1)){
echo "<option value=".$dbdepart1['EqName'].">".$dbdepart1['EqName']."</option>";
}
echo "</select>";
//ส่วนของ list ที่2
<div style="width:94%"id="option">
รายการ <select name="DeviceID">
<br />
<?php
$q="SELECT DeviceID,DeviceName,Unit FROM charge WHERE DeviceID LIKE '1%'";
$qr=mysql_query($q);
while($rs=mysql_fetch_array($qr)){
?>
<option value="<?=$rs['DeviceID']?>"><?=$rs['DeviceName']?><?=$rs['Unit']?></option>
<?php }?> <br /></select></div>
<div style="width:94%"id="option1">
รายการ <select name="DeviceID">
<?php
$q="SELECT DeviceID,DeviceName,Unit FROM charge WHERE DeviceID LIKE '2%'";
$qr=mysql_query($q);
while($rs=mysql_fetch_array($qr)){
?>
<option value="<?=$rs['DeviceID']?>"><?=$rs['DeviceName']?><?=$rs['Unit']?></option>
<?php }?> </select></div>
<div style="width:94%"id="option2">
รายการ <select name="DeviceID">
<?php
$q="SELECT DeviceID,DeviceName,Unit FROM charge WHERE DeviceID LIKE '3%'";
$qr=mysql_query($q);
while($rs=mysql_fetch_array($qr)){
?>
<option value="<?=$rs['DeviceID']?>"><?=$rs['DeviceName']?><?=$rs['Unit']?></option>
<?php }?> </select></div>
<div style="width:94%"id="option3">
รายการ <select name="DeviceID">
<?php
$q="SELECT DeviceID,DeviceName,Unit FROM charge WHERE DeviceID LIKE '4%'";
$qr=mysql_query($q);
while($rs=mysql_fetch_array($qr)){
?>
<option value="<?=$rs['DeviceID']?>"><?=$rs['DeviceName']?><?=$rs['Unit']?></option>
<?php }?> </select></div>
<div style="width:94%"id="option4">
รายการ <select name="DeviceID">
<?php
$q="SELECT DeviceID,DeviceName,Unit FROM charge WHERE DeviceID LIKE '5%'";
$qr=mysql_query($q);
while($rs=mysql_fetch_array($qr)){
?>
<option value="<?=$rs['DeviceID']?>"><?=$rs['DeviceName']?><?=$rs['Unit']?></option>
<?php }?></select></div>
<div style="width:94%"id="option5">
รายการ <select name="DeviceID">
<?php
$q="SELECT DeviceID,DeviceName,Unit FROM charge WHERE DeviceID LIKE '6%'";
$qr=mysql_query($q);
while($rs=mysql_fetch_array($qr)){
?>
<option value="<?=$rs['DeviceID']?>"><?=$rs['DeviceName']?><?=$rs['Unit']?></option>
<?php }?></select></div>
<div style="width:94%"id="option6">
รายการ <select name="DeviceID">
<?php
$q="SELECT DeviceID,DeviceName,Unit FROM charge WHERE DeviceID LIKE '7%'";
$qr=mysql_query($q);
while($rs=mysql_fetch_array($qr)){
?>
<option value="<?=$rs['DeviceID']?>"><?=$rs['DeviceName']?><?=$rs['Unit']?></option>
<?php }?></select></div>
<div style="width:94%"id="option7">
รายการ <select name="DeviceID">
<?php
$q="SELECT DeviceID,DeviceName,Unit FROM charge WHERE DeviceID LIKE '8%'";
$qr=mysql_query($q);
while($rs=mysql_fetch_array($qr)){
?>
<option value="<?=$rs['DeviceID']?>"><?=$rs['DeviceName']?><?=$rs['Unit']?></option>
<?php }?></select></div>([glow=red][glow=red]มันเก็บค่าสุดท้ายที่อยู่ใน select นี้[/glow][/glow])