<!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <?php include('includes/config.php')?> <script language = "JavaScript">/ function List(SelectValue) { frmMain.model.length = 0 var myOption = new Option('','') frmMain.model.options[frmMain.model.length]= myOption <? $intRows = 0; $strSQL = "SELECT * FROM tbl_model order by model_id "; $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); $intRows = 0; while($objResult = mysql_fetch_array($objQuery)) { $intRows++; ?> x = <?=$intRows;?>; mySubList = new Array(); strGroup = "<?=$objResult["brand_id"];?>"; strValue = "<?=$objResult["model_id"];?>"; strItem = "<?=$objResult["namem"];?>"; mySubList[x,0] = strItem; mySubList[x,1] = strGroup; mySubList[x,2] = strValue; if (mySubList[x,1] == SelectValue){ var myOption = new Option(mySubList[x,0], mySubList[x,2]) frmMain.model.options[frmMain.model.length]= myOption } <? } ?> } </script> <body> <form name="frmMain" action="" method="post"> Brand <select id="brand" name="brand" onChange = "List(this.value)"> <option selected value="">---Select Brand---</option> <? $strSQL = "SELECT * FROM tbl_brand ORDER BY brand_id "; $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); while($objResult = mysql_fetch_array($objQuery)) { ?> <option value="<?=$objResult["brand_id"];?>"> <?=$objResult["nameb"];?> </option> <? } ?> </select> Model <select id="model" name="model" style="width:150px"> <option value="">---Selct Model---</option> </select> </br> </form> <?php if(isset($_POST)){ include('includes/config.php'); $brand = $_POST['brand']; $model = $_POST['model']; $sql = "INSERT INTO tbl_stock_monitor (`brand` ,`model`)VALUES ('$brand','$model')"; $result = mysql_query($sql); if($result){ echo "<p align='center'><font color='#FF0000' >บันทึกข้อมูลเรียบร้อยแล้ว</font></p>"; }else{ echo "<p align='center'><font color='#FF0000' >การบันทึกข้อมูลผิดพลาด</font></p>"; } } ?> </body> </html>
<option value="<?=$objResult["nameb"];?>"> <?=$objResult["nameb"];?> </option>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง