</head> <script language="JavaScript"> var flag=0; function checkf_trade(){ var v1 = document.f_trade.origin_go.value; var v2 = document.f_trade.get_back.value; var v3 = document.f_trade.date_go.value; var v4 = document.f_trade.number_of.value; var v5 = document.f_trade.train_go.value; var v6 = document.f_trade.n_orders.value; var v7 = document.f_trade.call_orders.value; if ( v1.length == ""){ alert("กรุณาใส่สถานีต้นทาง"); document.f_trade.origin_go.focus(); return false; } else if (v2.length == ""){ alert("กรุณาใส่สถานีปลายทาง"); document.f_trade.get_back.focus(); return false; } else if (v3.length == ""){ alert("กรุณาใส่วันที่ออกเดินทาง"); document.f_trade.date_go.focus(); return false; } else if (v4.length == ""){ alert("กรุณาใส่จำนวนผู้โดยสาร"); document.f_trade.number_of.focus(); return false; } else if (v5.length == ""){ alert("กรุณาระบุขบวนรถ"); document.f_trade.train_go.focus(); return false; } else if (v6.length == ""){ alert("กรุณาระบุชื่อผู้จอง"); document.f_trade.n_orders.focus(); return false; } else if (v7.length == ""){ alert("กรุณาระบุเบอร์ติดต่อ"); document.f_trade.call_orders.focus(); return false; } else flag=1; return true; } </script> <body> <form id="f_trade" method="post" class="cssform" name="f_trade" action="" onSubmit="return checkf_trade();"> <p> <label for="origin_go">สถานีต้นทาง:</label> <select name="origin_go" class="list"> <option selected>สถานีต้นทาง</option> <?php require_once 'common/config.php'; $sql = "select * From station"; $table = mysql_query($sql,$conn) or die("ไม่สามารถเลือกตารางได้"); while($row = mysql_fetch_array($table)){ ?> <option value="<?=$row["id_station"];?>"><?=$row["Station"];?></option> <?php } ?> </select> <p> <label for="get_back">สถานีปลายทาง:</label> <select name="get_back" class="list"> <option selected>สถานีปลายทาง</option> <?php require_once 'common/config.php'; $sql = "select * From station"; $table = mysql_query($sql,$conn) or die("ไม่สามารถเลือกตารางได้"); while($row = mysql_fetch_array($table)){ ?> <option value="<?=$row["id_station"];?>"><?=$row["Station"];?></option> <?php } ?> </select> <p> <label for="date_go">วันที่ออกเดินทาง:</label> <input name="date_go" type="text" style="width: 80px;" maxlength="10" value=" "/> <a href="javascript:displayDatePicker('Date_go')"><img border="0" src="images/cal.gif" width="16" height="16"></a></p> <p> <label for="number_of">จำนวนผู้โดยสาร:</label> <input name="number_of" type="text" style="width: 50px;" maxlength="50" value=" "/> </p> <p> <label for="train_go">ขบวนรถ:</label> <select name="train_go" class="list"> <option selected>ขบวนรถ</option> <?php require_once 'common/config.php'; $sql = "select * From formation"; $table = mysql_query($sql,$conn) or die("ไม่สามารถเลือกตารางได้"); while($row = mysql_fetch_array($table)){ ?> <option value="<?=$row["id_formation"];?>"><?=$row["n_Formation"];?></option> <?php } ?> </select> </p> <p> <label for="n_orders">ชื่อผู้จองตั่ว:</label> <input name="n_orders" type="text" value=" " /> </p> <p> <label for="call_orders">โทรศัพท์:</label> <input name="call_orders" type="text" value=" " /> </p> <p> <label for="mail_orders">Email:</label> <input name="mail_orders" type="text" id="mail_orders" value=" " /> </p> <p> <label for="insist">รายละเอียด:</label><!-- ส่งสตริงที่ random ได้ไปสร้างรูปภาพ--> <textarea name="Detail_orders" id="Detail_orders" cols="45" rows="5"></textarea> <br> <input type="hidden" name="code_hidden" value="<?=$ran_str?>"><!-- ซ่อนสตริงไว้ในฟอร์มไว้ตรวจสอบกับค่าที่ผู้ใช้ input--> <br> <?php if(isset($_SESSION["ses_code_input"])) echo $_SESSION["ses_code_input"]; session_unregister('ses_code_input'); ?> </p> <br /> <div style="margin-left: 150px;"> <input type="submit" value="submit" /> <input type="reset" value="reset" /> </div> </form> </body> </html>
else if (v3.length < 2){ alert("กรุณาใส่วันที่ออกเดินทาง"); document.f_trade.date_go.focus(); return false; }
else if (v3 == " "){ alert("กรุณาใส่วันที่ออกเดินทาง"); document.f_trade.date_go.focus(); return false; }
function checkf_trade(){ var v1 = document.f_trade.origin_go; ... var v3 = document.f_trade.date_go; .... if ( v1.value == 0){ alert("กรุณาใส่สถานีต้นทาง"); document.f_trade.origin_go.focus(); return false; } if ( v1.value == ""){ alert("กรุณาใส่..."); document.f_trade.date_go.focus(); return false; } .... <select name="get_back" id="get_back" class="list"> ///----> อย่าลืม id ด้วยนะครับทุกตัวเลย <option selected value="0">ขบวนรถ</option> ....
<select name="origin_go" class="list"> <option value=" " selected="selected">ขบวนรถ</option> </select>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง