Home >Web Front-end >HTML Tutorial >When the checkbox in the foreground is selected, the selected content is saved in the background to the database_html/css_WEB-ITnose

When the checkbox in the foreground is selected, the selected content is saved in the background to the database_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 12:09:151527browse

Dear heroes, I need to implement a function now. There are several checkboxes in the HTML page. When the checkbox is checked, click the save button to save the text content behind the checked checkbox to the specified database.
The problem I am encountering now is how to transfer the selected status of the checkbox to the background. If it is text, I know that in js
.....
var aaa=document. getElementById("Text1").value;
.....
url:'../../Handler1.ashx?aaa=' aaa,
.....
But It won’t work when checking the box. Please give me some guidance. Beginners sincerely ask for advice


Reply to the discussion (solution)

js is a front-end script. Saving to the database requires a background script

Just determine whether the checkbox is selected in the background script
For example, asp
<%
if request.form("checkbox1")<>" " then
dim a=request.form("Text1")
' Insert
end if

%>

Write a global url when the checkbox is selected. ./../Handler1.ashx?ck=1 otherwise=0, in the code url:url

I have several checkboxes, can the person upstairs give more details?

Dear heroes, I need to implement a function now. There are several checkboxes in the HTML page. When the checkbox is checked, click the save button to save the text content behind the checked checkbox to the specified in the database.
The problem I am encountering now is how to transfer the selected status of the checkbox to the background. If it is text, I know that in js
.....
var aaa=document. getElementById("Text...
In the same way, select all selected checkboxes, traverse, set their values ​​to text content, and splice their values ​​together
$(':checked').each() {
var txt = $(this).val();
. //Splicing url:'../../Handler1.ashx?aaa,
}

What if it is a DataGrid? This checkbox has multiple records, and the checkbox value of multiple rows may be changed. How to save it to the database?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn