Click to See Complete Forum and Search --> : Query String Checkbox Values
baldwingrand
12-09-2008, 04:24 PM
I've attached some ASP code and a SQL SP. Not sure how much of this is needed to solve this issue. The problem I'm having is that I can't figure out how to pass in the values of my checkboxes into a query string. They are returning "undefined" on the page. Does anyone know off-hand what piece I am missing or writing incorrectly here? I am actually just trying to hard code values at the moment and even those are not coming up. I know there are such records because my stored procedure works. Thanks for any help.
gil davis
12-10-2008, 11:31 AM
If a checkbox is not checked on submit of the form, then you do not get a value pair in the querystring. The only time a checkbox shows up is if the box is checked.
baldwingrand
12-12-2008, 02:55 PM
Thanks. What I did was add a for loop for my checkboxes, so they actually do something now. It's working better, but in the query string is seeing "undefined" as the first value in the list. Ex: ",undefined,11,12" (11 and 12 being November and December). So I wonder why I'm still getting that?
My ASP code is the same; all i changed was to add this for loop:
for (i=0; i<=12; i++)
{
if (document.getElementById ("cbMonth" + i).checked)
{
MonthSelected = MonthSelected + "," + i;
}
}
for (i=0; i<=15; i++)
{
if (document.getElementById ("cbSite" + i).checked)
{
SiteSelected = SiteSelected + "," + document.getElementById("cbSite" + i).value;
}
}