Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Page Update!!!

Status
Not open for further replies.

wg26

Programmer
Mar 21, 2002
135
0
0
US
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 = &quot;VBScript&quot;>

Dim theItem(10, 4)
Dim ItemNum

Sub ItemSelected()
Dim strPassOver
strPassOver = document.location.search
strPassOver = Mid(strPassOver,2)
Dim ItemList
ItemList = split(strPassOver, &quot;;&quot;)
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 = &quot;&quot;
for theBoxNum=0 to ItemNum Step 2
if theItem(theBoxNum/2,3)>0 then
theLineItem = &quot;<TR ALIGN='center'><TD WIDTH=5% HEIGHT=25%><FONT face = 'Times New Roma' SIZE='+0.1' COLOR=DarkBlue>&quot;
theLineItem = theLineItem & &quot;<INPUT TYPE='text' SIZE=3 VALUE = 1 NAME='Qty' onChange = '&theItem(theBoxNum/2, 0)&'= Qty.Value'></FONT></TD>&quot;
theLineItem = theLineItem & &quot;<TD ><FONT face = 'Times New Roma' SIZE='+0.1' COLOR=DarkBlue >&quot; & theItem(theBoxNum/2,1) & &quot;</FONT></TD>&quot;
theLineItem = theLineItem & &quot;<TD ><FONT face = 'Times New Roma' SIZE='+0.1' COLOR='DarkBlue' >$ &quot; & theItem(theBoxNum/2,2) & &quot;</FONT></TD>&quot;
theLineItem = theLineItem & &quot;<TD ><FONT face = 'Times New Roma' SIZE='+0.1' COLOR='DarkBlue' >$ &quot; & theItem(theBoxNum/2,3) & &quot;</FONT></TD></TR>&quot;
TableCode = TableCode & theLineItem
TotalValue = TotalValue + theItem(theBoxNum/2,3)
end if
next
TableCode = TableCode & &quot; </TABLE>&quot;
ProductSelected = TableCode
End function

Sub UpdateOrder_OnClick()
Dim Tablecode,theLineItem, thePrice, theQty, totalNum
Dim strQuery
strQuery = &quot;?&quot;
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) & &quot;;&quot; & theItem(ItemIndex,1) & &quot;;&quot; & theItem(ItemIndex,2) & &quot;;&quot;
end if
next
if totalNum<>0 then
strQuery = Left(strQuery, Len(strQuery) - 1) document.location.href =&quot;MyUpdatePage.htm&quot; & strQuery
end if
End Sub

</SCRIPT>
</head>
<body>
<FORM NAME=&quot;ItemForm&quot;>
<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=&quot;VBScript&quot;>
document.write(&quot;<BODY BGCOLOR='white'><CENTER>&quot; & ProductSelected() & &quot;</CENTER>&quot;)
</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=&quot;VBScript&quot;>
document.write(&quot;<TD WIDTH=50%><FONT face = 'Times New Roma' SIZE='+0.1' COLOR='DarkBlue'>$ &quot; &TotalAmount()& &quot;</FONT></TD>&quot;)
</SCRIPT>
</TR></TABLE><br>
<TABLE WIDTH=100%>
<TR >
<INPUT TYPE=&quot;button&quot; NAME=&quot;UpdateOrder&quot; VALUE=&quot;Update Order&quot;>
</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!
 
make it simple on yourself. when the user clicks the update function, do the db update and then show the same page again. A simple way to do this to make the discrete parts into function or subs and then call them when things at that point

ex

Code:
if request.form(&quot;submit&quot;)=&quot;Update&quot; then
    call update_function
else
    call show_results
end if

sub update function 

'get the data from the form

'process the update

call show_results

end sub

sub show_results

' ASP and HTML code to show the contents of the cart

end sub

You'll find this is easier to build and maintain

Bastien

cat, the other other white meat
 
like the foot note.
cant say i enjoyed or new i was eating cat at the time!! bit on the greasy, flabby white chicken side for me,,,a bit like the stuff you get in my local chinese!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top