The idea of reading and inserting the checkbox in the ASP page cyclically

Source: Internet
Author: User
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 ")

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.