Hi Everyone,
I have a problem when I am trying to update the a page which is created based on the items user selected from previous page. and in this new page(second page), user can change the quantity of the items they selected, and press the update button. After the update button is clicked, the another page will be displayed with correct Qty and Total amount. Since I am really new to VBscript and web developing. I have a problem with how to pass the correct Qty to the new page. the following is my code in the second page. Can anyone please take a look the code and let me know what is wrong or how I should do it? Thanks a lot...
<html>
<head>
<title> My Text webpage </title>
<SCRIPT LANGUAGE = "VBScript">
Dim theItem(10, 4)
Dim ItemNum
Sub ItemSelected()
Dim strPassOver
strPassOver = document.location.search
strPassOver = Mid(strPassOver,2)
Dim ItemList
ItemList = split(strPassOver, ";"
ItemNum = UBound(ItemList)
for theBoxNum=0 to UBound(ItemList) Step 2
theItem(theBoxNum/2,0) = 1
theItem(theBoxNum/2,1) = ItemList(theBoxNum)
theItem(theBoxNum/2,2) = ItemList(theBoxNum+1)
thePrice = theItem(theBoxNum/2,2)
theQty = theItem(theBoxNum/2,0)
theItem(theBoxNum/2,3) = thePrice*theQty
Next
End Sub
function ProductSelected()
DIM theBoxNum,theLineItem, theLineHead, theLineTail, TableCode, thePrice, theQty
TotalValue = 0
ItemSelected()
TableCode = ""
for theBoxNum=0 to ItemNum Step 2
if theItem(theBoxNum/2,3)>0 then
theLineItem = "<TR ALIGN='center'><TD WIDTH=5% HEIGHT=25%><FONT face = 'Times New Roma' SIZE='+0.1' COLOR=DarkBlue>"
theLineItem = theLineItem & "<INPUT TYPE='text' SIZE=3 VALUE = 1 NAME='Qty' onChange = '&theItem(theBoxNum/2, 0)&'= Qty.Value'></FONT></TD>"
theLineItem = theLineItem & "<TD ><FONT face = 'Times New Roma' SIZE='+0.1' COLOR=DarkBlue >" & theItem(theBoxNum/2,1) & "</FONT></TD>"
theLineItem = theLineItem & "<TD ><FONT face = 'Times New Roma' SIZE='+0.1' COLOR='DarkBlue' >$ " & theItem(theBoxNum/2,2) & "</FONT></TD>"
theLineItem = theLineItem & "<TD ><FONT face = 'Times New Roma' SIZE='+0.1' COLOR='DarkBlue' >$ " & theItem(theBoxNum/2,3) & "</FONT></TD></TR>"
TableCode = TableCode & theLineItem
TotalValue = TotalValue + theItem(theBoxNum/2,3)
end if
next
TableCode = TableCode & " </TABLE>"
ProductSelected = TableCode
End function
Sub UpdateOrder_OnClick()
Dim Tablecode,theLineItem, thePrice, theQty, totalNum
Dim strQuery
strQuery = "?"
totalNum = 0
for ItemIndex = 0 to 10
'theItem(ItemIndex,0) = document.Itemform.Qty(ItemIndex).Value
if theItem(ItemIndex,0)> 0 then
totalNum = totalNum+1
StrQuery = StrQuery & theItem(ItemIndex,0) & ";" & theItem(ItemIndex,1) & ";" & theItem(ItemIndex,2) & ";"
end if
next
if totalNum<>0 then
strQuery = Left(strQuery, Len(strQuery) - 1) document.location.href ="MyUpdatePage.htm" & strQuery
end if
End Sub
</SCRIPT>
</head>
<body>
<FORM NAME="ItemForm">
<TABLE WIDTH=85% ALIGN=right BGCOLOR='Lightyellow' BORDER = 1><TR><TD><b>Shopping Cart:</b>
<TABLE WIDTH=100% BORDER=1 CELLSPACING=3 CELLPADDING=3><TR ALIGN=center BGCOLOR='lightyellow'>
<TD WIDTH=5% HEIGHT=25%><FONT face = 'Times New Roma' SIZE='+0.1' COLOR='Darkgreen' >Quantity</FONT></TD>
<TD WIDTH=55%><FONT face = 'Times New Roma' SIZE='+0.1' COLOR='Darkgreen'>Product Description</FONT></TD>
<TD WIDTH=20%><FONT face = 'Times New Roma' SIZE='+0.1' COLOR='Darkgreen'>Unit Price($)</FONT></TD>
<TD WIDTH=20%><FONT face = 'Times New Roma' SIZE='+0.1' COLOR='Darkgreen'>Total Amount($)</FONT></TD></TR>
<SCRIPT LANGUAGE="VBScript">
document.write("<BODY BGCOLOR='white'><CENTER>" & ProductSelected() & "</CENTER>"
</SCRIPT>
<TABLE WIDTH=38% BORDER=1 CELLSPACING=3 CELLPADDING=3 ALIGN='right'><TR ALIGN='center'>
<TD WIDTH =50%><FONT face = 'Times New Roma' SIZE='+0.1' COLOR='DarkBlue'>Total Amount:</FONT></TD>
<SCRIPT LANGUAGE="VBScript">
document.write("<TD WIDTH=50%><FONT face = 'Times New Roma' SIZE='+0.1' COLOR='DarkBlue'>$ " &TotalAmount()& "</FONT></TD>"
</SCRIPT>
</TR></TABLE><br>
<TABLE WIDTH=100%>
<TR >
<INPUT TYPE="button" NAME="UpdateOrder" VALUE="Update Order">
</TR>
</table>
</body>
</html>
As you can see, the problem is how to assign the value of theItem(theBoxNum,0) to the latest value so that it can be passed to the next page. I tried the all I can, but nothing works. document.Itemform.elements(num).value did not work.or the current code did work either...so please, help..
Sorry for the long post!
I have a problem when I am trying to update the a page which is created based on the items user selected from previous page. and in this new page(second page), user can change the quantity of the items they selected, and press the update button. After the update button is clicked, the another page will be displayed with correct Qty and Total amount. Since I am really new to VBscript and web developing. I have a problem with how to pass the correct Qty to the new page. the following is my code in the second page. Can anyone please take a look the code and let me know what is wrong or how I should do it? Thanks a lot...
<html>
<head>
<title> My Text webpage </title>
<SCRIPT LANGUAGE = "VBScript">
Dim theItem(10, 4)
Dim ItemNum
Sub ItemSelected()
Dim strPassOver
strPassOver = document.location.search
strPassOver = Mid(strPassOver,2)
Dim ItemList
ItemList = split(strPassOver, ";"
ItemNum = UBound(ItemList)
for theBoxNum=0 to UBound(ItemList) Step 2
theItem(theBoxNum/2,0) = 1
theItem(theBoxNum/2,1) = ItemList(theBoxNum)
theItem(theBoxNum/2,2) = ItemList(theBoxNum+1)
thePrice = theItem(theBoxNum/2,2)
theQty = theItem(theBoxNum/2,0)
theItem(theBoxNum/2,3) = thePrice*theQty
Next
End Sub
function ProductSelected()
DIM theBoxNum,theLineItem, theLineHead, theLineTail, TableCode, thePrice, theQty
TotalValue = 0
ItemSelected()
TableCode = ""
for theBoxNum=0 to ItemNum Step 2
if theItem(theBoxNum/2,3)>0 then
theLineItem = "<TR ALIGN='center'><TD WIDTH=5% HEIGHT=25%><FONT face = 'Times New Roma' SIZE='+0.1' COLOR=DarkBlue>"
theLineItem = theLineItem & "<INPUT TYPE='text' SIZE=3 VALUE = 1 NAME='Qty' onChange = '&theItem(theBoxNum/2, 0)&'= Qty.Value'></FONT></TD>"
theLineItem = theLineItem & "<TD ><FONT face = 'Times New Roma' SIZE='+0.1' COLOR=DarkBlue >" & theItem(theBoxNum/2,1) & "</FONT></TD>"
theLineItem = theLineItem & "<TD ><FONT face = 'Times New Roma' SIZE='+0.1' COLOR='DarkBlue' >$ " & theItem(theBoxNum/2,2) & "</FONT></TD>"
theLineItem = theLineItem & "<TD ><FONT face = 'Times New Roma' SIZE='+0.1' COLOR='DarkBlue' >$ " & theItem(theBoxNum/2,3) & "</FONT></TD></TR>"
TableCode = TableCode & theLineItem
TotalValue = TotalValue + theItem(theBoxNum/2,3)
end if
next
TableCode = TableCode & " </TABLE>"
ProductSelected = TableCode
End function
Sub UpdateOrder_OnClick()
Dim Tablecode,theLineItem, thePrice, theQty, totalNum
Dim strQuery
strQuery = "?"
totalNum = 0
for ItemIndex = 0 to 10
'theItem(ItemIndex,0) = document.Itemform.Qty(ItemIndex).Value
if theItem(ItemIndex,0)> 0 then
totalNum = totalNum+1
StrQuery = StrQuery & theItem(ItemIndex,0) & ";" & theItem(ItemIndex,1) & ";" & theItem(ItemIndex,2) & ";"
end if
next
if totalNum<>0 then
strQuery = Left(strQuery, Len(strQuery) - 1) document.location.href ="MyUpdatePage.htm" & strQuery
end if
End Sub
</SCRIPT>
</head>
<body>
<FORM NAME="ItemForm">
<TABLE WIDTH=85% ALIGN=right BGCOLOR='Lightyellow' BORDER = 1><TR><TD><b>Shopping Cart:</b>
<TABLE WIDTH=100% BORDER=1 CELLSPACING=3 CELLPADDING=3><TR ALIGN=center BGCOLOR='lightyellow'>
<TD WIDTH=5% HEIGHT=25%><FONT face = 'Times New Roma' SIZE='+0.1' COLOR='Darkgreen' >Quantity</FONT></TD>
<TD WIDTH=55%><FONT face = 'Times New Roma' SIZE='+0.1' COLOR='Darkgreen'>Product Description</FONT></TD>
<TD WIDTH=20%><FONT face = 'Times New Roma' SIZE='+0.1' COLOR='Darkgreen'>Unit Price($)</FONT></TD>
<TD WIDTH=20%><FONT face = 'Times New Roma' SIZE='+0.1' COLOR='Darkgreen'>Total Amount($)</FONT></TD></TR>
<SCRIPT LANGUAGE="VBScript">
document.write("<BODY BGCOLOR='white'><CENTER>" & ProductSelected() & "</CENTER>"
</SCRIPT>
<TABLE WIDTH=38% BORDER=1 CELLSPACING=3 CELLPADDING=3 ALIGN='right'><TR ALIGN='center'>
<TD WIDTH =50%><FONT face = 'Times New Roma' SIZE='+0.1' COLOR='DarkBlue'>Total Amount:</FONT></TD>
<SCRIPT LANGUAGE="VBScript">
document.write("<TD WIDTH=50%><FONT face = 'Times New Roma' SIZE='+0.1' COLOR='DarkBlue'>$ " &TotalAmount()& "</FONT></TD>"
</SCRIPT>
</TR></TABLE><br>
<TABLE WIDTH=100%>
<TR >
<INPUT TYPE="button" NAME="UpdateOrder" VALUE="Update Order">
</TR>
</table>
</body>
</html>
As you can see, the problem is how to assign the value of theItem(theBoxNum,0) to the latest value so that it can be passed to the next page. I tried the all I can, but nothing works. document.Itemform.elements(num).value did not work.or the current code did work either...so please, help..
Sorry for the long post!