Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

updating checkboxes

Status
Not open for further replies.

scroce

MIS
Nov 30, 2000
780
US
I have a form with about 24 checkboxes on it, and although this method works, there has to be something cleaner

I write this code once for each checkbox.

If Request.Form ("chkBdMem") = "true" then
objRS("BoardMember").value = true
else
objRS("BoardMember").value = false
end if


the value of each checkbox gets written back to yes/no field in an access database. I find if I don't do the if..then statement, if the user leaves the checkbox blank, the recordset doesn't get updated and an error is generated.



How much more water would there be in the ocean if it weren't for sponges?
 
In your access database, give each "check box item" an ID.
ID ITEM
-- -----
1 Border
2 Table
3 Cars
4 Sports
5 Houses

Then, on your form page, label your checkboxes as numbers, which would corospond to the ID in the database:
<input type='checkbox' name=1 id=1>Border<br>
<input type='checkbox' name=2 id=2>Table<br>
....

Finaly, on your process page (the one you are showing above), make a Do While loop

Dim iCount
iCount = 1

Do While Not iCount > 24
If (Request.Form(iCount) = True) Then
SQL = &quot;update mytable set value = true where id =&quot; & iCount
'...run your SQL
Else
SQL = &quot;update mytable set value = false where id =&quot; & iCount
'...run your SQL
iCount = iCount + 1
Loop

Is that something like you are looking for?
 
yes, i think this might work. - i'll give it a try How much more water would there be in the ocean if it weren't for sponges?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top