Click to See Complete Forum and Search --> : Problem with Checkboxes


stevem2004
08-06-2004, 11:08 AM
Hi,
I have a Access DB where users can fill in checkboxes when they fill in the form, however when I try to edit this form, how can I show them what has been selected in the checkboxes?

I have been trying to use the following code:-

<input name="mediasource" type="checkbox"<%if rs("mediasource") = "Mailing" then Response.write " checked" end if%>>Mailing<br>
But this doesn't show which check boxes have been ticked.

I have about 20 checkboxes in this group. Is the code above wrong??

TIA

Steve

gil davis
08-06-2004, 11:26 AM
If you view the source HTML, do you see the correct HTML?

If not, you have a problem in your compare. Perhaps rs("mediasource") is not a string value.

stevem2004
08-06-2004, 11:44 AM
Yes, the source is correct

buntine
08-06-2004, 11:47 PM
QueryString variables can only be strings. ASP is for very lazy developers. ;)

The reason it is not working is because checkBoxes will return the string "on" if they have been checked.

Regards,
Andrew Buntine.

Illufox
08-11-2004, 06:43 PM
I ran into the same problem. Here is the solution:

<input <%If (CStr((RecordsetName.Fields.Item("mediasource").Value)) = CStr("True")) Then Response.Write("checked") : Response.Write("")%> type="checkbox" name="mediasource" value="Yes">

buntine
08-11-2004, 09:13 PM
Just a note, you dont need to use CStr() on explicit string like "True". ;)

stevem2004
08-13-2004, 05:45 AM
Thanks everybody for your help, much appreciated