Jump to content

Checkbox Problem


alias92
 Share

Recommended Posts

i have a problem on checkboxes.<% counter3 = 0 dim gunler, guns, gun() gunler=split(dates,",") Redim gun(40) For each guns in gunler 'response.write "<br>gun(" & counter3 & ")=" & guns counter3 =counter3 + 1 Next counter2 = 0 For i = Cdate(start_date) to Cdate(end_date) If WeekdayName(Weekday(start_date)) <> "Sunday" Then %><input type="checkbox" name="dates" id="dates" value="<%=Cdate(start_date)%>" <%if CDate(start_date) = gunler(counter2) Then%> checked <%End If%>> <%=Cdate(start_date)%> - <%=WeekdayName(Weekday(start_date))%> <% End If start_date = DateAdd("d",1,start_date) counter2 = counter2 + 1 %><br> <%Next%> this is my code.i want to get checked checkbox from dbbut i cannot get checked checkbox because i write on db only checked, if i can write unchecked checkbox , i will be get the true solution.please give me a big helpgun(0)=22.08.2009gun(1)= 24.08.2009gun(2)= 25.08.2009gun(3)= 29.08.2009gun(4)= 01.09.2009gun(5)= 03.09.2009gun(6)= 04.09.2009gun(7)= 08.09.200922.08.2009 - Sat 24.08.2009 - Mon25.08.2009 - Tue26.08.2009 - Wed27.08.2009 - Thu28.08.2009 - Fri29.08.2009 - Sat31.08.2009 - Mon01.09.2009 - Tue02.09.2009 - Wed03.09.2009 - Thu04.09.2009 - Fri05.09.2009 - Sat07.09.2009 - Mon08.09.2009 - Tue09.09.2009 - Wed10.09.2009 - Thu11.09.2009 - Fri12.09.2009 - Sat14.09.2009 - Mon15.09.2009 - Tue

Edited by alias92
Link to comment
Share on other sites

If you want look at all of the boxes instead of only the ones that were checked, you need to loop through all of the checkbox names like you do when you write them out, and for each one see if it was submitted. In that case, it will probably help if you name each checkbox differently instead of calling them all the same thing.

Link to comment
Share on other sites

You already have a counter, so might as well use that for the name.counter2 = 0For i = Cdate(start_date) to Cdate(end_date) If WeekdayName(Weekday(start_date)) <> "Sunday" Then %><input type="checkbox" name="cb_<%=counter2%>" id="dates" value="<%=Cdate(start_date)%>" <%if CDate(start_date) = gunler(counter2) Then%> checked <%End If%>><%=Cdate(start_date)%> - <%=WeekdayName(Weekday(start_date))%><%End Ifstart_date = DateAdd("d",1,start_date)counter2 = counter2 + 1%><br><%Next%>Then to read them you do the same loop, and get each one by name.

counter = 0For i = Cdate(start_date) to Cdate(end_date)   cb = Request.Form("cb_" & counter)  ... do whatever with cb  counter = counter + 1Next

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...