<html>
<head>
<title>ThaiCreate.Com Tutorial</title>
</head>
<?
	//http://www.thaicreate.com/community/list-select-menu-auto-fill-textbox.html
	mysql_connect("localhost","root","bittersweet") or die(mysql_error());
	mysql_select_db("fishlanding");
?>

<script language="JavaScript">
	function resutName(strCusName)
	{
			frmMain.txtID.value = strCusName.split("|")[1];
			frmMain.txtName.value = strCusName.split("|")[2];
	}
</script>

<body>
	<form action="page.php" method="post" name="frmMain">
		List Menu 
		  <select name="lmName1" OnChange="resutName(this.value);">
			<option value=""><-- Please Select Item --></option>
			<?
			$strSQL = "SELECT * FROM fishspecies ORDER BY spid ASC";
			$objQuery = mysql_query($strSQL);
			while($objResult = mysql_fetch_array($objQuery))
			{
			?>
			<option value="<?=$objResult["spid"];?>|<?=$objResult["family"];?>|<?=$objResult["scientific"];?>"><?=$objResult["scientific"];?></option>
			<?
			}
			?>
		  </select>
		  <input name="txtID" type="text" value="" disabled>
		  <input name="txtName" type="text" value="" disabled>
	</form>
</body>
</html>
<?
	mysql_close();
?>

