Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > รบกวนดู Code ให้หน่อยครับ ต้องการให้มี alert ยืนยันก่อน add สินค้า ต้องเสริม Code ตรงไหน



 

รบกวนดู Code ให้หน่อยครับ ต้องการให้มี alert ยืนยันก่อน add สินค้า ต้องเสริม Code ตรงไหน

 



Topic : 048557



โพสกระทู้ ( 108 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook



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







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2010-09-10 15:18:36 By : evekrub View : 1059 Reply : 4
 

 

No. 1



โพสกระทู้ ( 11,835 )
บทความ ( 10 )

สมาชิกที่ใส่เสื้อไทยครีเอท Hall of Fame 2012

สถานะออฟไลน์


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
 


 

No. 2



โพสกระทู้ ( 108 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

ใส่ตามที่บอกแล้วอ่ะครับ เวลาเปิด Page ครั้งแรก ก็โชว์Alert เลยอ่ะครับ
อยากได้เวลากดสั่งซื้อค่อยโชว์อ่ะครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-09-10 21:55:00 By : evekrub
 

 

No. 3



โพสกระทู้ ( 2,249 )
บทความ ( 5 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook Hi5 Blogger

<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
 


 

No. 4



โพสกระทู้ ( 11,835 )
บทความ ( 10 )

สมาชิกที่ใส่เสื้อไทยครีเอท Hall of Fame 2012

สถานะออฟไลน์


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
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : รบกวนดู Code ให้หน่อยครับ ต้องการให้มี alert ยืนยันก่อน add สินค้า ต้องเสริม Code ตรงไหน
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 04
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่