codice:
<%
FUNCTION FixQuotes( theString )
FixQuotes = REPLACE( theString, "'", "''" )
END FUNCTION
function salvacart
IF Right(tot,2) = "00" Then
tot1=Int(Replace(tot, ".","",1, 1))
else
tot1=Replace(tot, ".","",1, 1)
tot1=Replace(tot1,",",".")
end if
SQL = "INSERT INTO summitcart (nmprodotto,qta,totprodotto,espositoreID )"
SQL = SQL & " VALUES('"
SQL = SQL & FixQuotes(descrizione) & "',"
SQL = SQL & FixQuotes(qta) & ","
SQL = SQL & FixQuotes(tot1) & ","
SQL = SQL & FixQuotes(mysession ) & ")"
conn.Execute(SQL)
end function
'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)
mysession = Session.SessionID
response.write Isempty(arrayForm )
response.write mysession
else
carrello = Session("cart")
mysession = Session.SessionID
response.write Isempty(arrayForm )
response.write mysession
end if
IF Request.Form.Count > 0 then
reDim arrayForm(1, 255)
intIndice = 0
For intLoop = 1 to Request.Form.Count
'se il numero di controlli del form e uguale a uno
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
'ridimensiono l'array alle giuste dimensioni, dato che ora
'conosco il numero di controlli del form e tolgo il campo invia
ReDim Preserve arrayForm(1, intIndice-1)
Session("cart") = arrayForm
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)
salvacart
end if
IF arrayForm (0,intIndice) = "BM" then
descrizione = arrayForm (1, intIndice)
qta = arrayForm (1, intIndice+1)
tot = arrayForm (1, intIndice+2)
salvacart
end if
IF arrayForm (0,intIndice) = "WK" then
descrizione = arrayForm (1, intIndice)
qta = arrayForm (1, intIndice+1)
tot = arrayForm (1, intIndice+2)
salvacart
end if
IF arrayForm (0,intIndice) = "RKIT" then
descrizione = arrayForm (1, intIndice)
qta = arrayForm (1, intIndice+1)
tot = arrayForm (1, intIndice+2)
salvacart
end if
Next
end if
%>
<%
Set rscart = Server.CreateObject("ADODB.Recordset")
sqlcart = "SELECT * FROM summitcart where espositoreID = " & mysession &""
rscart.open sqlcart, conn, 1, 3
if rscart.eof then
else
Response.write "va bene"
end if
%>
<%
conn.close
set conn=nothing
%>