Dim arr(10,1)
arr(0,0) = ww
arr(0,1) = xx
arr(1,0) = yy
arr(1,1) = zz
.
.
.
For i = 0 To UBound(arr)
Response.write arr(i,0) & "-" arr(i,1)
Next
Date :
2010-01-12 18:36:33
By :
webmaster
No. 3
Guest
ปัญหามีอยู่ว่า ค่าในfunction function GetAllProductList(Plist) ไม่ยอมส่งค่าที่บันทึกข้อมูลมาแสดงคะ
ตรง
for (var i = 0; i < allResult.length-1; i++){
ติดปัญหานี่นานและช่วยหน่อยคะ
พอ alert ค่าออกมาก็มีส่งมาคะ
///// connect.asp/////////
<%
set con =server.CreateObject("adodb.connection")
con.ConnectionString ="Provider=SQLOLEDB.1;Initial Catalog=Test;Data Source=Test;user id=sa;PASSWORD=Test"
con.Open
%>
//// end///
///////// ///////////
<!--#include file =connect.asp -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv='content-type' content='text/html' charset='windows-874'>
<title>การจัดการสินค้าคงคลังด้วย AJAX </title>
<link rel="stylesheet" type="text/css" href="Style.css" >
<script type="text/javascript">
var xmlHttp;
var number;
var Pid;
var title;
var result;
var price;
var picture;
function createXMLHttpRequest() {
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}
//เริ่มส่วนแสดงรายการสินค้า
function listProduct() {
var AllProductList = document.getElementById("AllProductList");
while(AllProductList.childNodes.length > 0) {
AllProductList.removeChild(AllProductList.childNodes[0]);
}
var url = "ListProduct.asp";
createXMLHttpRequest();
xmlHttp.onreadystatechange = handleListStateChange;
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}
function GetAllProductList(Plist) {
createHeadTable();
// var allResult=new Array();
allResult=Plist.split(",");
alert(allResult);
alert(allResult.length);
for (var i = 0; i < allResult.length-1; i++){
var result=allResult[i].split(":");
var row = document.createElement("tr");
var number = i+1;
var Pid = result[0];
var title = result[1];
var price = result[2];
var picture = result[3];
updateAllProductList(number, Pid, title, price, picture);
}
}
function createHeadTable() {
var row = document.createElement("tr");
row.appendChild(createCellWithText("ลำดับที่"));
row.appendChild(createCellWithText("ชื่อสินค้า"));
row.appendChild(createCellWithText("ราคา"));
row.appendChild(createCellWithText("รูปสินค้า"));
row.appendChild(createCellWithText("ลบสินค้า"));
row.appendChild(createCellWithText("ปรับปรุงสินค้า"));
row.style.background = "#ffcc99";
row.style.border = "0";
/////// ListProduct.asp //////
<!--#include file =connect.asp -->
<%
set rs1 =server.CreateObject("adodb.recordset")
sql1="select * from product_item order by id asc"
rs1.Open sql1,con,1,3
if not rs1.eof then
Response.Write(rs1.fields("id"))
Response.Write(rs1.fields("title"))
Response.Write(rs1.fields("price"))
Response.Write(rs1.fields("picture"))
end if
rs1.close
%>
///// End////
//// AddProduct.asp //////
<!--#include file =connect.asp -->
<%
set rs1 =server.CreateObject("adodb.recordset")
sql1 ="select * from product_item order by Id desc "
rs1.Open sql1,con,1,3
if not rs1.eof then
Id=rs1("id")+1
else
Id = 1
end if