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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checkboxes Stumped Me

Status
Not open for further replies.

mikecx

Technical User
Jul 9, 2002
215
US
I have a table with 5 colums to store the data pulled from the table. wd, wh, ld, pg, & sl. Not the easiest to remember but they mean things to me. I cant figure out how to make it so that All five checkboxes appear on one page, submit to the page itself, and then update the database. I have the form made, with the checkboxes having the correct values, and i have the code in place to have the page submit to itslef but for the life of me I cant get it to update the database right. To make things even more complicated, it needs to update only the row aqquired by the variable getname ( which is just a form on the page ). Please help.
 
If FormSubmitted() = True Then
UpdateDb()
End If

Function FormSubmitted()
If Request.Form(&quot;username&quot;) <> &quot;&quot; Then
FormSubmitted = True
Else
FormSubmitted = False
End If
End Function

Function UpdateDb()
Dim Db
Dim strSQL
Dim strTitle
Dim strText

getname = Request.Form(&quot;username&quot;)
'get the array with all of the checkbox id's
arrAll = split(Request.Form (&quot;allBoxes&quot;), &quot;,&quot;)

'get the array with the id's that were ticked
arrVals = split(Request.Form (&quot;chkBox&quot;), &quot;,&quot;)
Do While not i = 0 'to ubound(arrVals)
strSql = &quot;UPDATE dbo.users SET &quot; & arrVals(i) & &quot; = 1&quot; '& &quot;WHERE dbo.users.username = &quot; & &quot;'getname'&quot;
End
 
HI

strSql = &quot;UPDATE dbo.users SET &quot; & arrVals(i) & &quot; = 1&quot; '& &quot;WHERE dbo.users.username = &quot; & &quot;'getname'&quot;

I think it should be

strSql = &quot;UPDATE dbo.users SET &quot; & arrVals(i) & &quot; = 1 WHERE dbo.users.username = &quot; & &quot;'getname'&quot;

And you need to run the strSQL each time
ie.
conn.execute(strSQL)

Hope that helps

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top