At page1 I have 1 form include number checkbox equal number record in DB (which I used query to take) (checkboxs have the same name, value="rs('user')" )
Then I check in checkboxs...I want to take value of them at page2 and insert into database...
But then I used request.form("checkboxname"), I received 1 string as:" user1,user2,user3,user4" (as checkboxs which I choosed)

What must I do to insert serial values into the same filed in database ...
ex : user1 into group1, user2 into group1, user3 into group1, user4 into group1

Somebody help me...

Daemonspyre

04-04-2007, 07:52 PM

Welcome the SPLIT() function and array handling... I do this on a daily basis, so SPLIT would be the best way to start. Also, if you do not understand one-dimensional arrays, you need to study up on that first.

This is the array loop used to get the values out of the form. Starting at 0 (since all ASP arrays are zero-based), you will use the UBOUND() to get the upper limit of the array. Since HTML checkboxes ALWAYS add a ", " to everything, we don't want the highest number, but the second highest number, ubound()-1. The 'strSQL' SQL code is continued on with parentheses, single quotes, the HTML form value based on the array number, and lastly, single quotes, close parentheses, and a comma (to denote next value to enter into the database). The 'NEXT' loops you through this until you have reached the UPPER BOUND (ubound()).

Erase chkBoxArray

This is cleanup code. Always remember to destroy variables and arrays when you are done using them.

strSQL = left(strSQL,len(strSQL)-1)

Again, since we were using a LOOP, we have an extra comma on the end of the SQL statement. The line above removes that extra comma.

response.write(strSQL)
response.flush

Show me the command and flush the buffers. Use this to test your SQL to make sure that you have it right the first time.

Let me know if this is in anyway confusing or if you need any more help with this.

h2q1

04-05-2007, 04:16 AM

Thanks a lot :)

but there are some issues... (sorry because my English is so bad ! :()