Please enable JavaScript to view this site.

Navigation: Advanced topics > Events > Sample events > Database

Select multiple values to show as individual database entries

Scroll Prev Next More

 

To select multiple values from checkboxes or a list field and have them appear as individual database entries, use the following code in the Add page: Before Record Added event.

 

 

 

dim arr, i, strInsert
if values("fieldname")<>"" then
 arr = Split(values("fieldname"),",")
' This is the name of the multi check box or
' list select field, its value becomes arr
for i=lbound(arr) to ubound(arr)
   strInsert = "insert into TableName (field) values ('" & arr(i) & "')"
  ' add more fields from the add page to be inserted into database
   CustomQuery strInsert
next
 Response.Redirect "MyPage_list.asp"
' Exit and Redirect to the list page after updating database
exit function
end if

See also:

JavaScript API:getSelectedRecordKeys()

Database API: DB::Exec

Redirect to another page