|
|
|
ขอความช่วยเหลือ ด่วน!!! ส่งค่าตัวแปรจาก function จาก javascript ไป php ไม่ได้ |
|
|
|
|
|
|
|
*************** javascript ไปเรียก insertDataService.php? ให้insert ค่าลงตาราง****************
function addService() {
var servCode = document.getElementById("servCode").value;
var servName = document.getElementById("servName").value;
var servType = document.getElementById("servType1").value;
if (servCode == "" ||servName == "" ||servType == "") {
alert ("กรุณาข้อมูลให้ครบทุกช่อง");
return; }
var url = "insertDataService.php?servCode="+servCode+"&servName="+servName+"&servType="+servType;
createXMLHttpRequest();
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
displayInfo(xmlHttp.responseText);
} else {
displayInfo("พบข้อผิดพลาด: " + xmlHttp.statusText);
}
}// end if
};
xmlHttp.open("GET",url,true);
/*}*///end if
xmlHttp.send(null);
}// end addService
****************insertDataService.php**************
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<link href="style.css" rel="stylesheet" type="text/css" />
<link href="table-style.css" rel="stylesheet" type="text/css" />
</head>
</html>
<? include("StartConnect.inc");
$pservCode = $_POST["servCode"];
$pservName = $_POST["servName"];
$pservType = $_POST["servType"];
//echo "spcode=" .$pservCode;
$SQL = "INSERT INTO ICT_Service_M ";
$SQL .= "(SSRV_CODE,SSRV_NAME,SSRV_SSTP_CODE)";
$SQL .= "VALUES";
//$SQL.="('".$_POST["servCode"]."','".$_POST["servName"]."','"s.$_POST["servType"]."')";
$SQL .= "('.$pservCode.','.$pservName.','.$pservType.')";
//$SQL .="('003127','test','003')";
$objQuery = ociparse($Conn,$SQL);
$objExecute =oci_execute($objQuery,OCI_DEFAULT);
//echo $Conn. "insert complete";
if($objExecute)
{
oci_commit($Conn);
$strSQL = "SELECT * FROM ICT_Service_M WHERE Ssrv_Sstp_Code = $pservType";
$strSQL .= "ORDER BY 1 ";
$objQuery = ociparse($Conn,$strSQL);
//echo $objQuery ;
if (!$objExecute) {
$error = ocierror($Conn);
die($error); }
oci_execute($objQuery,OCI_DEFAULT);
$count=0;
?>
<table width="1140" align="left" >
<tr align="center"><!--หัวข้อตาราง-->
<td width="335"> </td>
<td width="78" height="27" align="center" background="../HD/images/tabheading.jpg"><div align="center"><span class="style1 style9 style2"><strong>ลำดับที่
</strong></span></div></td>
<td width="136" align="center" background="../HD/images/tabheading.jpg"><div align="center"><span class="style1 style9 style2"><strong>รหัสงานบริการ</strong>
</span></div></td>
<td width="192" align="center" background="../HD/images/tabheading.jpg"><span class="style1 style9 style2"><strong>ชื่องานบริการ</strong></span></td>
<td width="120" align="center" background="../HD/images/tabheading.jpg"><span class="style1 style9 style2"><strong>วันที่สร้าง</strong></span></td>
<td width="133" align="center" background="../HD/images/tabheading.jpg"><span class="style1 style9 style2"><strong>ผู้สร้าง</strong></span></td>
<td width="54" align="center" background="../HD/images/tabheading.jpg"><span class="style1 style9 style2"><strong>แก้ไข</strong></span></td>
<td width="56" align="center" background="../HD/images/tabheading.jpg"><span class="style1 style9 style2"><strong>ลบ</strong></span></td>
</tr>
<?
while($objResult = oci_fetch_array($objQuery))
{
?>
<!--<table width="1141" height="30" align="left" cellpadding="0" >-->
<tr bordercolor="#CCCCCC">
<td width="335"> </td>
<td width="81" align="center" bgcolor="#f7f7f7"><font size="2"><? echo $count+1;?></font></td>
<td width="140" align="center" bgcolor="#f7f7f7"><font size="2"><? echo $objResult['SSRV_CODE'];?></font></td>
<td width="194" align="left" bgcolor="#f7f7f7"><font size="2"><? echo $objResult['SSRV_NAME'];?></font></td>
<td width="121" bgcolor="#f7f7f7"> </td> <font size="2"> <? echo date(dd/mm/yyyy) ?> </font>
<td width="136" bgcolor="#f7f7f7"> </td> <font size="2"> </font>
<td width="57" align="center" bgcolor="#f7f7f7"><a href="updateDataService.php"><img src="images/page_edit.gif" width="16" height="16" /></a></td>
<td width="57" align="center" bgcolor="#f7f7f7"><a href="deleteDataService.php"><img src="images/page_text_delete.gif" width="16" height="16" /></a></td>
</tr>
<? $count++; ?>
<? } // end while ?>
<tr><td> </td></tr>
</table>
<? }// end if($objQuery) ?>
<?
oci_close($Conn);
?>
Tag : - - - -
|
|
|
|
|
|
Date :
2010-02-16 19:22:29 |
By :
little Bee |
View :
1463 |
Reply :
0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|