ladybugz46
Technical User
Hi, I am back with this vbscript pricing array I have developed. It works great on an item details page, that is, on a single item page. It now needs to work on a page of search results with multiple items.
The way I have it configured it runs the array once and then gives me a runtime error type mismatch at the line where the array is dim-ed.
It needs to run every time an item is placed on the page.
I have tried a do until loop that uses the total amount of items in the cart and it won't load the page.
Any ideas would be welcome......would love to look at code you are willing to share where something similar has been done.
Thanks in advance!!! suez code is below
array and code (in a file include)
there is a chunk pulled out of the middle of it just for simplicity's sake.
<%Dim sku
sku = Cstr(itmno)
Dim outletPrice(259,2)
outletPrice(251,0) = "511673GF"
outletPrice(251,1) = "28.34"
outletPrice(252,0) = "511682GF"
outletPrice(252,1) = "15.36"
outletPrice(253,0) = "511681GF"
outletPrice(253,1) = "10.97"
outletPrice(254,0) = "511680GF"
outletPrice(254,1) = "11.64"
outletPrice(255,0) = "511684GF"
outletPrice(255,1) = "9.93"
outletPrice(256,0) = "511685GF"
outletPrice(256,1) = "16.5"
outletPrice(257,0) = "511689GF"
outletPrice(257,1) = "17.55"
outletPrice(258,0) = "511384GF"
outletPrice(258,1) = "12.7"
outletPrice(259,0) = "511690GF"
outletPrice(259,1) = "11.31"
'origPrice is what is uploaded to macs
'outletPrice is what is in the array (given to us by merchandising)
Dim origPrice
origPrice = itmpri
For i = LBound(outletPrice) to UBound(outletPrice)
Dim savings
savings = origPrice / outletPrice(i,1)
if outletPrice(i,0) = sku Then
response.write("<font size=1 color=#ff0000><B>SAVE " & FormatPercent(savings,0) & " </B></font><br>"
response.write("<font face=Arial,Verdana,helvetica size=1 color=#999999><b>Regular Price: " & FormatCurrency(outletPrice(i,1)) & "</b></font><br>"
response.write("<font face=Arial,Verdana,helvetica size=1 color=#000099><b>NOW ONLY:</b></font> <font size=1 color=#ff0000><b>" & FormatCurrency(origPrice) & "</font></b><BR>"
else
End if
next
%>
the following is the page code:
<table width="570" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF">
<TR bgcolor="FFFFFF"><td>
<%
DIM itmedp
dim itmno
dim itmdesc
dim itmprc
dim itminv
dim itmavl
dim itmpri
dim itmvar
dim imgovr
For icount = 1 to pgln
itmedp = trim(trans03.GetValue("ItemEdp",cint(icount)))
itmno = trim(trans03.GetValue("ItemNo",cint(icount)))
itmdesc = trans03.GetValue("ItemDescription",cint(icount))
itmpri = trans03.GetValue("ItemPrice",cint(icount))
itminv = trim(trans03.GetValue("ItmAvailableInv",cint(icount)))
itmvar = trans03.GetValue("ItemIdVar",cint(icount))
imgovr = trim(trans03.GetValue("ItmImageOvrd",cint(icount)))
if itmedp = "" then exit for
if itminv > "0" then itmavl = "IN STOCK" else itmavl = "Out of Stock"
'if itmpri = ** then itmprc = "Select For Price" else itmprc = itmpri
if len(trim(imgovr)) = 0 then
imgovr = itmedp
end if
thePath = "images\" & imgovr & ".jpg"
Set fs=Server.CreateObject("Scripting.FileSystemObject"
If (fs.FileExists(Server.Mappath(thePath)))=false Then
thePic = "images\default.jpg"
else
thePic = "images\" & imgovr & ".jpg"
end if
Set fs=nothing
%>
<table width="100%" align="center" border="0" bgcolor="#ffffff"><tr bgcolor="#ffffff">
<!-- Image Display -->
<td align="left" valign="top" width="100">
<A href="details_os.asp?PN=<% =itmno %>&UID=<% =cuid %>&UPS1=1&GEN1=<% Response.Write(Gen1Str) %>"><img SRC="<% =thepic %>" border="0"></a>
</td>
<!-- Description Display -->
<td align="left" valign="top" width="253"><font face="arial, helvetica, san-serif" size="-2" color="#000066">Item Description</font><br>
<A href="details_os.asp?PN=<% =itmno %>&UID=<% =cuid %>&UPS1=1&GEN1=<% Response.Write(Gen1Str) %>"><font size=1 face="arial, helvetica, san-serif"><% =itmdesc %></font></A><br><font face="arial, helvetica, san-serif" size="-2" color="#000066">Order #</font> <font face="arial, helvetica, san-serif" size=1><b><% =itmno %></b></font><br><font face="arial, helvetica, san-serif" size=1 color="#000066">- <% =itmavl %> -</font></td>
<!-- Item Price Display -->
<%<td align="center" valign="top" width="230">
<!-- loop for multi-pricing -->
<table width="100%" border="0">
<tr>
<TD>
<!--#INCLUDE FILE = "jscript/outlet_array_os.asp" -->
</td>
</tr>
</table>
<!-- end loop for multi-pricing -->
many many thanks!! suez
should be able to view the error here:
The way I have it configured it runs the array once and then gives me a runtime error type mismatch at the line where the array is dim-ed.
It needs to run every time an item is placed on the page.
I have tried a do until loop that uses the total amount of items in the cart and it won't load the page.
Any ideas would be welcome......would love to look at code you are willing to share where something similar has been done.
Thanks in advance!!! suez code is below
array and code (in a file include)
there is a chunk pulled out of the middle of it just for simplicity's sake.
<%Dim sku
sku = Cstr(itmno)
Dim outletPrice(259,2)
outletPrice(251,0) = "511673GF"
outletPrice(251,1) = "28.34"
outletPrice(252,0) = "511682GF"
outletPrice(252,1) = "15.36"
outletPrice(253,0) = "511681GF"
outletPrice(253,1) = "10.97"
outletPrice(254,0) = "511680GF"
outletPrice(254,1) = "11.64"
outletPrice(255,0) = "511684GF"
outletPrice(255,1) = "9.93"
outletPrice(256,0) = "511685GF"
outletPrice(256,1) = "16.5"
outletPrice(257,0) = "511689GF"
outletPrice(257,1) = "17.55"
outletPrice(258,0) = "511384GF"
outletPrice(258,1) = "12.7"
outletPrice(259,0) = "511690GF"
outletPrice(259,1) = "11.31"
'origPrice is what is uploaded to macs
'outletPrice is what is in the array (given to us by merchandising)
Dim origPrice
origPrice = itmpri
For i = LBound(outletPrice) to UBound(outletPrice)
Dim savings
savings = origPrice / outletPrice(i,1)
if outletPrice(i,0) = sku Then
response.write("<font size=1 color=#ff0000><B>SAVE " & FormatPercent(savings,0) & " </B></font><br>"
response.write("<font face=Arial,Verdana,helvetica size=1 color=#999999><b>Regular Price: " & FormatCurrency(outletPrice(i,1)) & "</b></font><br>"
response.write("<font face=Arial,Verdana,helvetica size=1 color=#000099><b>NOW ONLY:</b></font> <font size=1 color=#ff0000><b>" & FormatCurrency(origPrice) & "</font></b><BR>"
else
End if
next
%>
the following is the page code:
<table width="570" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF">
<TR bgcolor="FFFFFF"><td>
<%
DIM itmedp
dim itmno
dim itmdesc
dim itmprc
dim itminv
dim itmavl
dim itmpri
dim itmvar
dim imgovr
For icount = 1 to pgln
itmedp = trim(trans03.GetValue("ItemEdp",cint(icount)))
itmno = trim(trans03.GetValue("ItemNo",cint(icount)))
itmdesc = trans03.GetValue("ItemDescription",cint(icount))
itmpri = trans03.GetValue("ItemPrice",cint(icount))
itminv = trim(trans03.GetValue("ItmAvailableInv",cint(icount)))
itmvar = trans03.GetValue("ItemIdVar",cint(icount))
imgovr = trim(trans03.GetValue("ItmImageOvrd",cint(icount)))
if itmedp = "" then exit for
if itminv > "0" then itmavl = "IN STOCK" else itmavl = "Out of Stock"
'if itmpri = ** then itmprc = "Select For Price" else itmprc = itmpri
if len(trim(imgovr)) = 0 then
imgovr = itmedp
end if
thePath = "images\" & imgovr & ".jpg"
Set fs=Server.CreateObject("Scripting.FileSystemObject"
If (fs.FileExists(Server.Mappath(thePath)))=false Then
thePic = "images\default.jpg"
else
thePic = "images\" & imgovr & ".jpg"
end if
Set fs=nothing
%>
<table width="100%" align="center" border="0" bgcolor="#ffffff"><tr bgcolor="#ffffff">
<!-- Image Display -->
<td align="left" valign="top" width="100">
<A href="details_os.asp?PN=<% =itmno %>&UID=<% =cuid %>&UPS1=1&GEN1=<% Response.Write(Gen1Str) %>"><img SRC="<% =thepic %>" border="0"></a>
</td>
<!-- Description Display -->
<td align="left" valign="top" width="253"><font face="arial, helvetica, san-serif" size="-2" color="#000066">Item Description</font><br>
<A href="details_os.asp?PN=<% =itmno %>&UID=<% =cuid %>&UPS1=1&GEN1=<% Response.Write(Gen1Str) %>"><font size=1 face="arial, helvetica, san-serif"><% =itmdesc %></font></A><br><font face="arial, helvetica, san-serif" size="-2" color="#000066">Order #</font> <font face="arial, helvetica, san-serif" size=1><b><% =itmno %></b></font><br><font face="arial, helvetica, san-serif" size=1 color="#000066">- <% =itmavl %> -</font></td>
<!-- Item Price Display -->
<%<td align="center" valign="top" width="230">
<!-- loop for multi-pricing -->
<table width="100%" border="0">
<tr>
<TD>
<!--#INCLUDE FILE = "jscript/outlet_array_os.asp" -->
</td>
</tr>
</table>
<!-- end loop for multi-pricing -->
many many thanks!! suez
should be able to view the error here: