The statement for deleting multiple checkboxes is:
Delete from table where ID in request. Form ("ID ")
If it is a form, there are some input boxes, and there is a checkbox with many selection boxes, after selecting the checked of the checkbox, how can I write the selected value and other information in the form to the database?
The idea is as follows: assume a. asp has
<Input type = "checkbox" name = "ID" value = "variable ID">
The id value here is different. There are dozens of options.
Form to B. asp,
In B. asp, the first thing to do is to check the number of IDS selected in A. ASP as the checkbox status.
Syntax:
Count = request. Form ("ID"). Count
If the calculated count is 35, 35 checkboxes with the name ID are selected. That is to say, 35 data records need to be written into the database. The cycle is as follows:
For I = 1 to count
Id = request. Form ("ID") (I)
Here is the SQL General insert statement. When the ID above is the selected record as I, when the I-th condition is read, the ID variable value
Next
Another method is roughly the same, but the method for getting the number of loops is different.
I have many checkboxes in the form, with the same name. I hope to select multiple boxes and write them into the database.
then I thought about it and decided to read it cyclically
dim SQL, project_id, expert_name, expert_namestr
project_id = request. form ("project_id")
expert_namestr = request. form ("expert_name")
expert_namestr = Split (expert_namestr ,",") ''split function separates expert_namestr by commas (,).
for I = 0 to ubound (expert_namestr) '''ubound function to obtain the maximum number of separated strings
expert_name = expert_namestr (I)
set rs = server. createobject ("ADODB. recordset ")
SQL =" select * From pingfen where pingfen_project_id = "& project_id
Rs. open SQL, Conn, 1, 3
If RS. EOF then
SQL = "insert into pingfen (pingfen_project_id, pingfen_expert_name) values ('" & project_id & "', '" & expert_name &"') "
conn.exe cute (SQL)
else
RS (" pingfen_expert_name ") = expert_name
SQL =" Update pingfen set pingfen_expert_na Me = '"& expert_name &"' Where pingfen_project_id = "& project_id
conn.exe cute (SQL)
end if
next
call alertandjump ("operation successful! "," ../Admin/fenpeizhuanjia. asp "," Smile ")