|
|
|
รบกวนดู Code ให้หน่อยครับ ต้องการให้มี alert ยืนยันก่อน add สินค้า ต้องเสริม Code ตรงไหน |
|
|
|
|
|
|
|
Code (PHP)
<html>
<head>
<title>Shopping</title>
<script language="JavaScript">
var HttPRequest = false;
function doCallAjax(ProductID,Qty) {
HttPRequest = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
HttPRequest = new XMLHttpRequest();
if (HttPRequest.overrideMimeType) {
HttPRequest.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) { // IE
try {
HttPRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
HttPRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!HttPRequest) {
alert('Cannot create XMLHTTP instance');
return false;
}
var url = 'ShoppingCart2.php';
var pmeters = "tProductID=" + ProductID+
"&tQty=" + Qty;
HttPRequest.open('POST',url,true);
HttPRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
HttPRequest.setRequestHeader("Content-length", pmeters.length);
HttPRequest.setRequestHeader("Connection", "close");
HttPRequest.send(pmeters);
HttPRequest.onreadystatechange = function()
{
if(HttPRequest.readyState == 3) // Loading Request
{
document.getElementById("mySpan").innerHTML = "Now is Loading...";
}
if(HttPRequest.readyState == 4) // Return Request
{
document.getElementById('mySpan').innerHTML = HttPRequest.responseText;
}
}
}
function CheckOut()
{
window.location = 'ShoppingCart3.php';
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
<body onLoad="JavaScript:doCallAjax('','')">
<table width="590" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top">
<?
include("connect.php");
$strSQL = "SELECT * FROM product ORDER BY ProductID ASC ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
echo"<table border=\"0\" cellspacing=\"1\" cellpadding=\"1\" width=\"590\" ><tr>";
$intRows = 0;
while($objResult = mysql_fetch_array($objQuery))
{
$intRows++;
echo "<td>";
?>
<img src="product/<?=$objResult["Picture"];?>" width="150" height="200" border="0">
<br>
<?=$objResult["ProductName"];?>
<br>
<?="ราคา ".number_format($objResult["Price"],2)." บาท";?>
<br>
<input type="hidden" id="txt<?=$intRows;?>" value="1" style="width:50px">
<input type="button" value="Add" onDblClick="hello()" onClick="JavaScript:doCallAjax('<?=$objResult["ProductID"];?>',document.getElementById('txt<?=$intRows;?>').value);">
</center>
<?
echo"</td>";
if(($intRows)%3==0)
{
echo"</tr>";
}
else
{
echo "<td>";
}
}
echo"</tr></table>";
?>
<?
mysql_close($con);
?> </td>
</tr>
</table>
<span id="mySpan"></span>
</body>
</html>
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2010-09-10 15:18:36 |
By :
evekrub |
View :
1084 |
Reply :
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<font class="detailDesc"><font class="css_code"><html>
<head>
<title>Shopping</title>
<script language="JavaScript">
var HttPRequest = false;
function doCallAjax(ProductID,Qty) {
HttPRequest = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
HttPRequest = new XMLHttpRequest();
if (HttPRequest.overrideMimeType) {
HttPRequest.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) { // IE
try {
HttPRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
HttPRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!HttPRequest) {
alert('Cannot create XMLHTTP instance');
return false;
}
if(confirm("จริงป๊ะะะ?")){
var url = 'ShoppingCart2.php';
var pmeters = "tProductID=" + ProductID+
"&tQty=" + Qty;
HttPRequest.open('POST',url,true);
HttPRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
HttPRequest.setRequestHeader("Content-length", pmeters.length);
HttPRequest.setRequestHeader("Connection", "close");
HttPRequest.send(pmeters);
HttPRequest.onreadystatechange = function()
{
if(HttPRequest.readyState == 3) // Loading Request
{
document.getElementById("mySpan").innerHTML = "Now is Loading...";
}
if(HttPRequest.readyState == 4) // Return Request
{
document.getElementById('mySpan').innerHTML = HttPRequest.responseText;
}
}
}
}
function CheckOut()
{
window.location = 'ShoppingCart3.php';
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
<body onLoad="JavaScript:doCallAjax('','')">
<table width="590" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top">
<?
include("connect.php");
$strSQL = "SELECT * FROM product ORDER BY ProductID ASC ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
echo"<table border=\"0\" cellspacing=\"1\" cellpadding=\"1\" width=\"590\" ><tr>";
$intRows = 0;
while($objResult = mysql_fetch_array($objQuery))
{
$intRows++;
echo "<td>";
?>
<img src="product/<?=$objResult["Picture"];?>" width="150" height="200" border="0">
<br>
<?=$objResult["ProductName"];?>
<br>
<?="ราคา ".number_format($objResult["Price"],2)." บาท";?>
<br>
<input type="hidden" id="txt<?=$intRows;?>" value="1" style="width:50px">
<input type="button" value="Add" onDblClick="hello()" onClick="JavaScript:doCallAjax('<?=$objResult["ProductID"];?>',document.getElementById('txt<?=$intRows;?>').value);">
</center>
<?
echo"</td>";
if(($intRows)%3==0)
{
echo"</tr>";
}
else
{
echo "<td>";
}
}
echo"</tr></table>";
?>
<?
mysql_close($con);
?> </td>
</tr>
</table>
<span id="mySpan"></span>
</body>
</html>
</font></font>
|
|
|
|
|
Date :
2010-09-10 15:46:52 |
By :
PlaKriM |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ใส่ตามที่บอกแล้วอ่ะครับ เวลาเปิด Page ครั้งแรก ก็โชว์Alert เลยอ่ะครับ
อยากได้เวลากดสั่งซื้อค่อยโชว์อ่ะครับ
|
|
|
|
|
Date :
2010-09-10 21:55:00 |
By :
evekrub |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<font class="detailDesc"><font class="css_code"><html>
<head>
<title>Shopping</title>
<script language="JavaScript">
var HttPRequest = false;
function doCallAjax(ProductID,Qty) {
HttPRequest = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
HttPRequest = new XMLHttpRequest();
if (HttPRequest.overrideMimeType) {
HttPRequest.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) { // IE
try {
HttPRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
HttPRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!HttPRequest) {
alert('Cannot create XMLHTTP instance');
return false;
}
if(confirm("จริงป๊ะะะ?")){
var url = 'ShoppingCart2.php';
var pmeters = "tProductID=" + ProductID+
"&tQty=" + Qty;
HttPRequest.open('POST',url,true);
HttPRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
HttPRequest.setRequestHeader("Content-length", pmeters.length);
HttPRequest.setRequestHeader("Connection", "close");
HttPRequest.send(pmeters);
HttPRequest.onreadystatechange = function()
{
if(HttPRequest.readyState == 3) // Loading Request
{
document.getElementById("mySpan").innerHTML = "Now is Loading...";
}
if(HttPRequest.readyState == 4) // Return Request
{
document.getElementById('mySpan').innerHTML = HttPRequest.responseText;
}
}
}
}
function CheckOut()
{
window.location = 'ShoppingCart3.php';
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
<body onLoad="JavaScript:doCallAjax('','')">
<table width="590" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top">
<?
//include("connect.php");
$strSQL = "SELECT * FROM product ORDER BY ProductID ASC ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
echo"<table border=\"0\" cellspacing=\"1\" cellpadding=\"1\" width=\"590\" ><tr>";
$intRows = 0;
while($objResult = mysql_fetch_array($objQuery))
{
$intRows++;
echo "<td>";
?>
<img src="product/<?=$objResult["Picture"];?>" width="150" height="200" border="0">
<br>
<?=$objResult["ProductName"];?>
<br>
<?="ราคา ".number_format($objResult["Price"],2)." บาท";?>
<br>
<input type="hidden" id="txt<?=$intRows;?>" value="1" style="width:50px">
<input type="button" value="Add" onclick="alert('คุณต้องการซื้อสินค้านี้ใช่หรือไม่');" onClick="JavaScript:doCallAjax('<?=$objResult["ProductID"];?>',document.getElementById('txt<?=$intRows;?>').value);">
</center>
<?
echo"</td>";
if(($intRows)%3==0)
{
echo"</tr>";
}
else
{
echo "<td>";
}
}
echo"</tr></table>";
?>
<?
mysql_close($con);
?> </td>
</tr>
</table>
<span id="mySpan"></span>
</body>
</html>
</font></font>
|
|
|
|
|
Date :
2010-09-10 22:00:42 |
By :
Manussawin |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<head>
<title>Shopping</title>
<script language="JavaScript">
var HttPRequest = false;
function doCallAjax(ProductID,Qty) {
HttPRequest = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
HttPRequest = new XMLHttpRequest();
if (HttPRequest.overrideMimeType) {
HttPRequest.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) { // IE
try {
HttPRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
HttPRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!HttPRequest) {
alert('Cannot create XMLHTTP instance');
return false;
}
if(confirm("จริงป๊ะะะ?")){
var url = 'ShoppingCart2.php';
var pmeters = "tProductID=" + ProductID+
"&tQty=" + Qty;
HttPRequest.open('POST',url,true);
HttPRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
HttPRequest.setRequestHeader("Content-length", pmeters.length);
HttPRequest.setRequestHeader("Connection", "close");
HttPRequest.send(pmeters);
HttPRequest.onreadystatechange = function()
{
if(HttPRequest.readyState == 3) // Loading Request
{
document.getElementById("mySpan").innerHTML = "Now is Loading...";
}
if(HttPRequest.readyState == 4) // Return Request
{
document.getElementById('mySpan').innerHTML = HttPRequest.responseText;
}
}
}
}
function CheckOut()
{
window.location = 'ShoppingCart3.php';
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
<body>
<table width="590" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top">
<?
include("connect.php");
$strSQL = "SELECT * FROM product ORDER BY ProductID ASC ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
echo"<table border=\"0\" cellspacing=\"1\" cellpadding=\"1\" width=\"590\" ><tr>";
$intRows = 0;
while($objResult = mysql_fetch_array($objQuery))
{
$intRows++;
echo "<td>";
?>
<img src="product/<?=$objResult["Picture"];?>" width="150" height="200" border="0">
<br>
<?=$objResult["ProductName"];?>
<br>
<?="ราคา ".number_format($objResult["Price"],2)." บาท";?>
<br>
<input type="hidden" id="txt<?=$intRows;?>" value="1" style="width:50px">
<input type="button" value="Add" onClick="JavaScript:doCallAjax('<?=$objResult["ProductID"];?>',document.getElementById('txt<?=$intRows;?>').value);">
</center>
<?
echo"</td>";
if(($intRows)%3==0)
{
echo"</tr>";
}
else
{
echo "<td>";
}
}
echo"</tr></table>";
?>
<?
mysql_close($con);
?> </td>
</tr>
</table>
<span id="mySpan"></span>
</body>
</html>
|
|
|
|
|
Date :
2010-09-11 00:13:42 |
By :
PlaKriM |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|