Skip to main content
Participant
Nov 3, 2006 9:22 PM UTC
Question

Dynamic checkbox not displaying correctly

I've been going round in circles trying to solve my problem of dynamic checkboxes in an ASP script and I was wondering if anyone can help me. In addition, I've read the Ultradev pages on Adding dynamic content for checkboxes and I can't see what I'm doing wrong.

The check box links to a Yes/No field in MS Access. I have created a filtered recordset.

I want this checkbox in a form that has an update server behavior.

The code for the checkbox that gets generated is:

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

However the above code doesn't display a 'check' or 'uncheck' when the content of the field in the database is 'true' or 'false' respectively. (I've added a control field to view the content of the field - this displays the content of the Yes/No field as 'true' or 'false'). Once manually checked or unchecked by the user, the checkbox updates the database correctly. The problem appears to be only with the display of the content of the Yes/No field using the checkbox.

Many thanks
Sandra

This topic is closed to new replies. Start a new post to keep the conversation going.

1 reply

Inspiring
Nov 7, 2006 2:39 AM UTC
Hi Sandra,

Have you tried using 1/0 or Yes/No as opposed to True/False?

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

...or:

<input <%If (CStr((rsViewAccess.Fields.Item("fldReadTerms").Value)) =
CStr("1")) Then Response.Write("checked=""checked""") :
Response.Write("")%>
name="checkbox" type="checkbox" value="checkbox" checked="checked" />

Please note, the above code may not be correct, I'm just using it to
illustrate that you could try "Yes" or "1" rather than "True", to see if it
makes a difference.

I hope this is useful.

Regards
Nath.

"Database Novice" <webforumsuser@macromedia.com> wrote in message
news:eigbtp$rn7$1@forums.macromedia.com...
> I've been going round in circles trying to solve my problem of dynamic
> checkboxes in an ASP script and I was wondering if anyone can help me. In
> addition, I've read the Ultradev pages on Adding dynamic content for
> checkboxes
> and I can't see what I'm doing wrong.
>
> The check box links to a Yes/No field in MS Access. I have created a
> filtered
> recordset.
>
> I want this checkbox in a form that has an update server behavior.
>
> The code for the checkbox that gets generated is:
>
> <input <%If (CStr((rsViewAccess.Fields.Item("fldReadTerms").Value)) =
> CStr("True")) Then Response.Write("checked=""checked""") :
> Response.Write("")%>
> name="checkbox" type="checkbox" value="checkbox" checked="checked" />
>
> However the above code doesn't display a 'check' or 'uncheck' when the
> content
> of the field in the database is 'true' or 'false' respectively. (I've
> added a
> control field to view the content of the field - this displays the content
> of
> the Yes/No field as 'true' or 'false'). Once manually checked or
> unchecked by
> the user, the checkbox updates the database correctly. The problem
> appears to
> be only with the display of the content of the Yes/No field using the
> checkbox.
>
> Many thanks
> Sandra
>
>
>


Translate