Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Re: Getting check boxes to display in asp database results


Message #1 by "Imar Spaanjaars" <Imar@S...> on Sun, 12 May 2002 15:27:51
Hi there,

It indeed looks like you need to use some if / then statements to 
determine the value in the database and then write the word "selected" as 
an attribute for the checkbox. You could clean this up a little by 
getting the values for each record first into variables, and then use 
these variables to build the HTML table. This is a bit cleaner that 
messing HTML and ASP.

Something like this:

   Dim sValue
   Dim bChecked
   Dim sChecked
   sChecked = ""
   sValue = myRecordset("Name")
   bChecked = myRecordset("BooleanField")
   If bChecked = True then ' You may need some casting here
      sChecked = " selected"
   end if

Response.Write ("<tr><td>" & sValue & "</td><td><input type=""checkbox""" 
& sChecked & " value=""aValue"" /></td></tr>"

Another option is to let the database return the word "checked" when the 
value of the field is true. In Access you can use IIF to return different 
values depending on the value of a field. {personally, I don't like this 
solution too much, as it binds your Access database to HTML output, which 
may not always be appropriate).


HtH

Imar

> I am using a somewhat simple access database which has a table of info 
l> inked to a secondary table which has many, many options for the user 
to 
s> elect from. ( many check boxes)  In placing this online, I wish for 
the 
w> eb browser to be able to view this as one would in access, with the 
a> ppropriate boxes checked or unchecked.  Al I can manage to accomplish 
is 
g> e a rather clunky table with a bunch of TRUE or False's in the 
fields.  
C> an anyone help me get this solved.  

> I know on an entry screen how to accomplish this, by using standard 
form 
e> lements. The problem here is this is a view only screen.

> Thank you in advance..

> Tony
Message #2 by "Tony Dodd" <tdodd@t...> on Sun, 12 May 2002 05:47:07
I am using a somewhat simple access database which has a table of info 
linked to a secondary table which has many, many options for the user to 
select from. ( many check boxes)  In placing this online, I wish for the 
web browser to be able to view this as one would in access, with the 
appropriate boxes checked or unchecked.  Al I can manage to accomplish is 
ge a rather clunky table with a bunch of TRUE or False's in the fields.  
Can anyone help me get this solved.  

I know on an entry screen how to accomplish this, by using standard form 
elements. The problem here is this is a view only screen.

Thank you in advance..

Tony

  Return to Index