|
 |
|
ต้องการเช็คค่างว่างและinsert ลง database (ทำไม ie insert 2 รอบ Firefox รอบเดียว) |
|
 |
|
|
 |
 |
|
งงมากลองทดสอบกับ ie ปรากฏว่า insert ลง DB 2 รอบ แต่ Firefox รอบเดียว จะมีทางไหนสามารถแก้ให้รองรับทั้งสอง browser บ้าง
Code (PHP)
/* javascript */
function chknull()
{
if(document.frmAddCatagory.typename.value==""||document.frmAddCatagory.typename.value==null)
{
alert('Please insert typename !');
document.frmAddCatagory.typename.focus();
return false;
}
if(document.frmAddCatagory.typedetail.value==""||document.frmAddCatagory.typedetail.value==null)
{
alert('Please insert typedetail !');
document.frmAddCatagory.typedetail.focus();
return false;
}
return true;
/*document.frmAddCatagory.submit();*/
}
/*----------------------------------------------------------------------------------*/
/* form */
<form id="frmAddCatagory" name="frmAddCatagory" method="POST" action="insert_catagory.php" onsubmit="return chknull();">
<table width="100%" cellspacing="0" cellpadding="1" bordercolor="#ffffff" border="1" class="textform">
<tbody>
<tr bgcolor="#7db00d"> <td height="30" colspan="3">
<table width="100%" height="20" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td width="25%" align="left">
<span class="subheadnews">
เพิ่มหมวด
</span>
</td>
<td align="right" width="75%"> </td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td height="25" width="25%" bgcolor="#e5e5e5" align="right">
<span class="subhead">
ชื่อหมวด :
</span>
</td>
<td height="25" bgcolor="#e5e5e5" colspan="2" align="left">
<input type="text" name="typename" id="typename" />
</td>
</tr>
<tr>
<td class="subhead_over" width="25%" height="50" align="right" valign="top" bgcolor="#fffafa">
<span class="subhead">
รายละเอียด :
</span>
</td>
<td height="220" bgcolor="#e5e5e5" colspan="2" align="left">
<textarea class="textform" name="typedetail" id="typedetail" style="
background-color: rgb(255, 255, 238); font-family: MS Sans Serif; font-size: 10pt; border-style: solid;
border-width: 1px;" cols="54" rows="12" ></textarea>
</td>
</tr>
<tr bgcolor="#e5e5e5">
<td height="30" colspan="3" align="center" bgcolor="#e5e5e5">
<span class="subhead">
<font color="#ff0000"><input type="submit" name="btnSubmit" value="บันทึก" />
</font>
</span>
</td>
</tr>
</tbody>
</table>
</form>
/*----------------------------------------------------------------------------------------------*/
/* insert_catagory.php */
<?
$typename = $_POST['typename'];
$typedetail = $_POST['typedetail'];
//echo $typename."<br />".$typedetail; มีค่า
include "connect.php";
include "function.php";
$today = date("Y-m-d H:i:s");
$sql1 = "INSERT INTO kmtype (typename,typedetail,groupid,typedate,typeflag)
VALUES ('$typename','$typedetail','1','$today','0')";
$result1 = mysql_db_query($dbname,$sql1);
if($result1)
{
// echo "บันทึกเรียบร้อยแล้ว";
echo "<script language='JavaScript'>";
echo "alert('บันทึกเรียบร้อยแล้ว');"; //ถ้า alertตอนนี้มันจะ error head ครับ
// echo "window.close();";
echo "window.location='manage_catagory.php'";
// echo "window.opener.location.reload();";
// echo "<meta http-equiv='refresh' content='0;URL=manage_catagory.php?'>";
echo "</script>";
}
else
{
// echo "บันทึกไม่ได้";
echo "<script language='JavaScript'>";
echo "alert('บันทึกไม่ได้');"; //ถ้า alertตอนนี้มันจะ error head ครับ
// echo "window.close();";
echo "window.location='add_catagory.php'";
// echo "window.opener.location.reload();";
// echo "<meta http-equiv='refresh' content='0;URL=manage_catagory.php?'>";
echo "</script>";
}
mysql_close($link);
?>
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2010-03-03 15:42:46 |
By :
lCeng |
View :
1255 |
Reply :
5 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมว่าเป็นที่การแปล code ของ IE นะครับ
|
 |
 |
 |
 |
Date :
2010-03-03 15:58:19 |
By :
SOUL |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่น่ามีปัญหาครับ ลองเช็คดูดีๆครับ
|
 |
 |
 |
 |
Date :
2010-03-03 16:10:22 |
By :
pjgunner |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เช็คแล้วนะครับ งง ๆ อยู่เหมือนเดิม มัน ie มัน insert ซ้ำ 2 รอบจิง ๆ รบกวนช่วยดู ช่วยแนะให้หน่อย พอมีผู้รู้คนไหนแนะนำวิธีเขียนที่ดีกว่าแบบนี้บ้าง ขอความกรุณาด้วย T_T
|
 |
 |
 |
 |
Date :
2010-03-04 09:11:04 |
By :
lCeng |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เคยเป็น ครับ งง มาก IE ลง 2 ตาราง
FireFox ลง 1
Chorme ลง1
อยากรุเหมือนกัน
code ไม่ผิด นะครับ
step 1 ต่อ base
step 2 code sql
sterp3 mysql_query
step4 close
เทพตอบที ไม่ได้มีการวนลูปอะไรเลย อะ
|
 |
 |
 |
 |
Date :
2010-03-05 12:14:09 |
By :
deathzap |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
หน้าฟอร์มกับหน้า insert อยู่ไฟล์เดียวกันปะ ถ้าอยู่หน้าเดียวกันมันจะมีการคิวรี 2 รอบ คือรอบแรกตอนโหลดหน้าเพราะคุณไม่ได้มีการตรวจสอบเลยว่าถ้าโหลดหน้าไม่ต้อง Insert และอีกรอบตอนคุณ submit
แต่ถ้าคุณแยกไฟล์กัน ลองเอาพวก include ออกก่อน แล้วลองรันดู ไล่หาไปเรื่อยๆเดียวเจอเอง
|
 |
 |
 |
 |
Date :
2010-03-05 21:36:42 |
By :
naskw |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|