<html> <head> <title>ThaiCreate.Com Tutorial</title> </head> <?php mysql_connect("localhost","root","") or die(mysql_error()); mysql_select_db("mydatabase"); ?> <body> <form action="page.php" method="post" name="frmMain"> List Menu <select name="lmName1" OnChange="window.location='?item='+this.value;"> <option value=""><-- Please Select Item --></option> <?php $strSQL = "SELECT * FROM customer ORDER BY CustomerID ASC"; $objQuery = mysql_query($strSQL); while($objResult = mysql_fetch_array($objQuery)) { if($_GET["item"] == $objResult["CustomerID"]) { $sel = "selected"; } else { $sel = ""; } ?> <option value="<?php echo $objResult["CustomerID"];?>" <?php echo $sel;?>><?=$objResult["CustomerID"];?></option> <?php } ?> </select> <?php if($_GET["item"] != "") { $strSQL = "SELECT * FROM customer WHERE CustomerID = '".$_GET["item"]."' "; $objQuery = mysql_query($strSQL); $objResult2 = mysql_fetch_array($objQuery); } ?> <input name="txtName" type="text" value="<?php echo $objResult2["Name"];?>"> </form> </body> </html> <?php mysql_close(); ?>
<html> <meta http-equiv="Content-Type" content="text/html; charset=tis-620"> <script type="text/javascript"> var aa=[]; var bb=[]; </script> <? mysql_connect("localhost","root","") or die(mysql_error()); mysql_select_db("mydatabase"); mysql_query("set character_set_results=tis620"); mysql_query("set character_set_connection=tis620"); mysql_query("set character_set_client=tis620"); $strSQL = "SELECT * FROM customer ORDER BY CustomerID ASC"; $objQuery = mysql_query($strSQL); $nu=mysql_num_rows($objQuery); while($r = mysql_fetch_array($objQuery)) { $product_id[]=$r[CustomerID]; $product_name[]=$r[Name]; } for($i=0;$i<$nu;$i++){ $a[$i]=$product_id[$i]; $b[$i]=$product_name[$i]; ?> <script type="text/javascript"> var nu=<?=$nu?>; aa[<?=$i?>]=<?=$a[$i]?>; bb[<?=$i?>]='<?=$b[$i]?>'; </script> <? } ?> <script type="text/javascript"> function b(value) { var ab=value-1; if(value){ document.getElementById('product_name').value = bb[ab]; return false; } else{ document.getElementById('product_name').value = ""; } } </script> <body> <!-- ส่วนหัวของฟอร์มที่เป็นการบอกว่าจะให้ไปหน้าไหน หลังกดปุ่ม Submit --> <form action="page.php" method="post" onsubmit="return checkform(this);"> List Menu <select name="lmName" OnChange="return b(value)"> <option value=""><-- Please Select Item --></option> <?php for($i=0;$i<$nu;$i++){ ?> <option value="<?php echo $a[$i];?>"><?=$a[$i];?></option> <?php } ?> </select> <input name="product_name[]" type="text" size="30" id="product_name"> <input type="submit" name="Submit" value="ส่งข้อมูล"> </form> </body> </html>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง