Click to See Complete Forum and Search --> : retrieve values of checkbox


esthera
11-19-2007, 02:50 AM
i'm trying to retrieve the values of my checkbox
see demo below - it's not working
what am i doing wrong



<%
numproducts=request("numproducts")
response.write "Number of Products" & numproducts
if i<>"" then
for num = 1 to numproducts
if request.form("productid"& num)<>"" then
response.write "productid" & num & " is checked.
"
end if
next
end if

%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>



<body>
<form method=post>
test 1 <input type="checkbox" name="productid1" value"1">


test 2
<input type="checkbox" name="productid2" value"3851">


test 3
<input type="checkbox" name="productid3" value"3899">



test 4
<input type="checkbox" name="productid4" value"45345">




test 5
<input type="checkbox" name="productid5" value"3834">
<input type=hidden name=numproducts value=6>

<input type=submit name=submit value="test">
</form>
</body>
</html>

trymbill
11-19-2007, 06:15 AM
Why don't you just name each check box "productid[]" and let ASP grab the array productid[] submitted by the form. Much simpler :)