Forum Moderators: open

Message Too Old, No Replies

Checkbox Array i think

help!

         

Andrew Thomas

8:26 am on Apr 29, 2003 (gmt 0)

10+ Year Member



Can someone guide me or provide sample code in ASP as how to create a checkbox array. I posted a problem a while ago, but still havent fixed it?

Im getting a list from an access database which contains the following fields

Code Title Price

From this i create a list with a repeat region in dreamweaver with a check box included

[checkbox] AAA A widget £10.00
[checkbox] AA1 A red Widget £15.00
etc.....

the problem is all my checkboxes have the same name, ive also tried using the code as the checkbox name (so they are all different) but when i POST to the results page if more than one checkbox is ticked nothing shows up, if i check one box that one is displayed.

Any ideas, is it this page that is wrong or the results page.

thanks

I can email the link if required

sullen

8:34 am on Apr 29, 2003 (gmt 0)

10+ Year Member



You need to check which page is causing the problem - in principle there's no reason why this won't work.

Have you tried writing all the form contents to screen?

<%
for each FormItem in request.form
response.write FormItem & ": " & request.form(FormItem) & "<br>"
next
%>

will show you exactly what you're getting.

Is the form using method=post? If not it could be that there are too many variables for the URL.

If you are definately not getting the variables, then there must be something wrong with the form. Don't know what though!

Digga

8:39 am on Apr 29, 2003 (gmt 0)

10+ Year Member



Hi Andrew,

within the Repeat Region code, dim a counter, change the checkbox name/id attributes to read ="myBox<%=counter%>" and before the movenext record increment the counter by, 1 counter = counter + 1.

That should do it.

If you're unsure, post your code and I'll change it for you.

Digga

Sharing Knowledge Saves Valuable Time!

Andrew Thomas

9:07 am on Apr 29, 2003 (gmt 0)

10+ Year Member



Thanks digga, ive just emailed ya my code

Digga

9:30 am on Apr 29, 2003 (gmt 0)

10+ Year Member



Hi Andrew,

I've replied to your e-mail.

Digga

Sharing Knowledge Saves Valuable Time!

Digga

9:32 am on Apr 29, 2003 (gmt 0)

10+ Year Member



Hi Andrew,

just spotted an error, change this:

id="<%= (rs_SEAD.Fields.Item("tblProduct_A_Code").Value) & SEADCounter%>

to:

id="<%= (rs_SEAD.Fields.Item("tblProduct_A_Code").Value & SEADCounter)%>

Andrew Thomas

9:48 am on Apr 29, 2003 (gmt 0)

10+ Year Member



thanks digga

Digga

1:42 pm on Apr 29, 2003 (gmt 0)

10+ Year Member



Just needed to point out that I didn't read the question correctly and gave an incorrect answer.

The checkbox array is created by giving all the checkboxes the same name/id attribute. The values can be retrieved by request("checkboxName") the multiple values selected on the form are then concatenated together and seperated by a comma and a space - value1, value2, value3

Hopefully normal service will resume shortly and apologies for misleading anyone reading this thread.

Andrew Thomas

12:51 pm on Apr 30, 2003 (gmt 0)

10+ Year Member



A BIG Thanks to Digga who has stickied me loads of times today and yesterday for his help. Without him id be in a right mess :)

He has fixed the problem for me and has answered every question i had - so this thread has been fixed im happy to say. - if any one wished to see the code please sticky me

Once again thanks Digga