<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
 <head> 
  <title> new document </title> 
 </head> 
 
 <body> 
 <script language="JavaScript" type="text/javascript">
function showText(id1)
{
  document.getElementById('textId').value = document.getElementById(id1).value; // textId คือค่าของ textbox ที่ต้องการแสดงผล
}
</script>
<select name="erp" id="Faculty" style="width:200px" onchange = "showText('this.value')">
<? 
$host="localhost";
$user="root";
$password="bittersweet";
$dbname="fishlanding";
$connection=mysql_connect($host,$user,$password) or die("เชื่อมต่อฐานข้อมูลไม่ได้");
mysql_select_db($dbname) or die("ไม่สามารถเลือกฐานข้อมูลได้");
$cs1 = "SET character_set_results=tis620";
mysql_query($cs1) or die('Error query: ' . mysql_error());
$cs2 = "SET character_set_client = tis620";
mysql_query($cs2) or die('Error query: ' . mysql_error());

$cs3 = "SET character_set_connection = tis620";
mysql_query($cs3) or die('Error query: ' . mysql_error());
$sql="select * from fishspecies order by spid ASC";
$dbquery=mysql_db_query($dbname,$sql);
while($result=mysql_fetch_array($dbquery)){

?>
<option value="<?=$result[spid];?>" selected="selected"><?=$result[scientific];?></option>
<? 


echo "<input type=\"hidden\" name=\"$result[spid]\" value=\"$result[spid]\" >"; //ซ่อนไอดีและค่าไว้เรียกใช้งาน
}
?>
</select>

 </body> 
</html>
