codice:
<%
'creiamo un array bidimensionale, un po abbondante visto
' che non conosco il numero di controlli del form
IF NOT IsArray(Session("cart")) Then
reDim arrayForm(1, 255)
else
arrayForm = Session("cart")
response.write Isempty(arrayForm )
response.write mysession
end if
'se il numero di controlli del form è MAGGIORE di 0
IF Request.Form.Count > 0 then
reDim arrayForm(1, 255)
intIndice = 0
For intLoop = 1 to Request.Form.Count
valore = Request.Form(intLoop)
IF Isnumeric(valore) then
valore = Cint(valore)
end if
IF valore <> "0" then
'immagazzino nell'array le coppie nome-controllo/valore-controllo
campo1 = Request.Form.Key(intLoop)
campo2 = Request.Form.Item(intLoop)
IF Isnumeric(campo2) then
campo2 = TRIM(Replace(campo2,"€",""))
end if
arrayForm(0, intIndice) = campo1
arrayForm(1, intIndice) = campo2
intIndice = intIndice + 1
end if
next
ReDim Preserve arrayForm(1, intIndice-1)
Session ("cart") = arrayForm
end if
%>
<%
For intIndice = 0 To UBound(arrayForm , 2)
IF arrayForm (0,intIndice) = "ST" then
descrizione = arrayForm (1, intIndice)
qta = arrayForm (1, intIndice+1)
tot = arrayForm (1, intIndice+2)
'Response.Write "Descrizione: " & descrizione &" - " & qta &" - " & tot &"
"
end if
IF arrayForm (0,intIndice) = "BM" then
descrizione = arrayForm (1, intIndice)
qta = arrayForm (1, intIndice+1)
tot = arrayForm (1, intIndice+2)
'Response.Write "Descrizione: " & descrizione &" - " & qta &" - " & tot &"
"
end if
IF arrayForm (0,intIndice) = "WK" then
descrizione = arrayForm (1, intIndice)
qta = arrayForm (1, intIndice+1)
tot = arrayForm (1, intIndice+2)
'Response.Write "Descrizione: " & descrizione &" - " & qta &" - " & tot &"
"
end if
IF arrayForm (0,intIndice) = "RKIT" then
descrizione = arrayForm (1, intIndice)
qta = arrayForm (1, intIndice+1)
tot = arrayForm (1, intIndice+2)
end if
Next
sconto = 0
imponibile = 0
Response.Write "<table align=center><thead><tr>"
Response.Write "<th width=200>Nome Prodotto</th>"
Response.Write "<th width=2></th>"
Response.Write "<th width=50>Quantità</th>"
Response.Write "<th width=2></th>"
Response.Write "<th width=150>Totale</th></tr></thead>"
Response.Write "<tbody>"
For i = 0 to ubound (arrayForm ,2)
IF arrayForm (0,i) = "ST" then
descrizione = arrayForm (1,i)
qta = arrayForm (1, i+1)
tot = arrayForm (1, i+2)
sconto = (sconto + (tot * 0.5))
%>
<tr><TD width=200><%=descrizione%></TD>
<TD Class=tdbordo></td>
<TD align=center width=50><%=qta%></TD>
<TD class=tdbordo></td>
<td align=right width=150><%=FormatCurrency(tot)%></td></tr>
<%
end if
IF arrayForm (0,i) = "BM" then
descrizione = arrayForm (1,i)
qta = arrayForm (1, i+1)
tot = arrayForm (1, i+2)
sconto = (sconto + (tot * 0.5))
%>
<tr><TD width=200><%=descrizione%></TD>
<TD Class=tdbordo></td>
<TD align=center width=50><%=qta%></TD>
<TD class=tdbordo></td>
<td align=right width=150><%=FormatCurrency(tot)%></td></tr>
<%
end if
IF arrayForm (0,i) = "WK" then
descrizione = arrayForm (1,i)
qta = arrayForm (1, i+1)
tot = arrayForm (1, i+2)
sconto = (sconto + (tot * 0.5))
%>
<tr><TD width=200><%=descrizione%></TD>
<TD Class=tdbordo></td>
<TD align=center width=50><%=qta%></TD>
<TD class=tdbordo></td>
<td align=right width=150><%=FormatCurrency(tot)%></td></tr>
<%
end if
IF arrayForm (0,i) = "RKIT" then
descrizione = arrayForm (1,i)
qta = arrayForm (1, i+1)
tot = arrayForm (1, i+2)
sconto = (sconto + (tot * 0.5))
Response.Write "<tr>"
%>
<TD width=200><%=descrizione%></TD>
<TD Class=tdbordo></td>
<TD align=center width=50><%=qta%></TD>
<TD class=tdbordo></td>
<td align=right width=150><%=FormatCurrency(tot)%></td></tr>
<%
end if
next
imponibile = imponibile - sconto
IVA = imponibile * 0.21
totale = imponibile + IVA
%>
<TR><TD colspan=4 class=tdfoot align=right>Sconto 50%</TD><TD align=right class=tdfoot><font color=red>-<%=(FormatCurrency(sconto))%></font></td></tr>
<td colspan=4 align=right>Imponbile:</td><td align=right><%=FormatCurrency(imponibile)%></td></tr><tr>
<td colspan=4 align=right>IVA 21%:</td><td align=right><%=FormatCurrency(IVA)%></td></tr><TR>
<TD colspan=5 class=linea></td></tr>
<TR><td colspan=4 align=right>TOTALE</td><td align=right><%=FormatCurrency(totale)%></td>
</TR>
</tbody></table>