mettre les valeurs des checkbox dans une variable de session
Bonjour,
j'ai travaille en asp avec une base access.
j'ai un formulaire qui contient une liste du produits avec checkbox qui prend en valeur l'id de chaque produit.
Lorsque je selecte deux ou troix produits avec checkbox les valeurs de ces checkbox seront sauvegardé dans une variable de session. Et aprés je voulais revenir dans ce formulaire une autre fois et reselectionné une autre fois deux autres produits qui seront rajouté à la liste des produits choisi dans la premiére fois.
Mon code est le suivant :
formulaire
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
<% if(Request("Submit") <> "") then
sql = "SELECT * FROM produits as P, categorie as C where C.id_pcat = "&request.Form("ref_categorie")&" AND C.id_cat = "&request.Form("categorie")&" AND P.id_cat = C.id_cat"
Set prod = Server.CreateObject("ADODB.Recordset")
prod.Open sql, conn, 3, 3
nhist = prod.recordcount
%>
<form action="check_kit.asp" method="post">
<table width="850px" border="0" cellpadding="0" cellspacing="0" class="display" id="example">
<thead>
<tr>
<th width="65" rowspan="2" class="sorting">Image</th>
<th width="86" rowspan="2" class="sorting_asc">Référence</th>
<th rowspan="2" class="sorting">Désignation</th>
<th width="41" rowspan="2" class="sorting">PR</th>
<th rowspan="2" class="sorting">PV</th>
<th colspan="2" class="sorting">Marge</th>
<th width="87" rowspan="2" class="sorting">Prix <br>revendeur</th>
<th colspan="2" class="sorting">Marge</th>
<th width="48" rowspan="2"> </th>
</tr>
<tr>
<th width="45">≠ % PV</th>
<th width="45">%</th>
<th width="45">≠ % PR</th>
<th width="40">%</th>
</tr>
</thead>
<tbody>
<% if (nhist = 0) then
else
prod.movefirst
do while not prod.eof
%>
<tr class="gradeA odd">
<td align="center"><img src="../../image_picto/<%=prod.fields("Image_vignette")%>" hspace="1" vspace="1" border="0" title="<%=prod.fields("Titre_Prod")%>"></td>
<td><%=prod.fields("Ref_prod")%></td>
<td width="250"><%=prod.fields("Titre_Prod")%></td>
<td align="center"><%
PR=formatnumber( prod.fields.item("prix_achat")+ prod.fields.item("Prix_revient") , 2 )
response.write(PR)
%></td>
<td width="100" align="center"><% PrixHTprom=prod.fields("PrixHTprom_Prod")
PrixHT_Prod=prod.fields("PrixHT_Prod")
if prod.fields("Prom_Prod")=1 then
prix = formatnumber(PrixHTprom)
end if
if prod.fields("Prom_Prod")=0 then
prix =formatnumber(PrixHT_Prod)
end if
response.write(prix)
%> </td>
<td width="50" align="center"><%
marge=formatnumber((prix-PR), 2)
response.write(marge)
%></td>
<td width="45" align="center"><% percent=formatnumber((((prix/PR)-1)*100),2)
response.write(percent)
%></td>
<td align="center"><%=prod.fields("PrixHTrev_Prod")%></td>
<td width="50" align="center"><% marge2=formatnumber(prod.fields("PrixHTrev_Prod")-PR,2)
response.write(marge2) %></td>
<td width="45" align="center"><% percent2=formatnumber((((prod.fields("PrixHTrev_Prod")/PR)-1)*100),2)
response.write(percent2) %></td>
<td class="center"><input name="choix[]" type="checkbox" id="choix[]" value="<%=prod.fields("Id_Prod")%>"></td>
</tr>
<%
prod.movenext
loop
end if%>
</tbody>
</table><br>
<br>
<div>
<div align="right">
<input name="ok" type="submit" value="Valider et continuer">
</div>
</div>
</form>
<% end if %> |
page check_kit.asp
Code:
1 2 3 4 5 6 7 8 9 10
|
<%
My_Array=split(request.form("choix"),", ")
For Each item In My_Array
Session("choix") = item
response.write(Session("choix")&"<br>")
Next
response.redirect("nouveau_kit.asp")
%> |
Avez vous une idée???
Merci d'avance