Home > Web Front-end > JS Tutorial > jquery automatically fills the check box, that is, marks the check box with true_jquery

jquery automatically fills the check box, that is, marks the check box with true_jquery

WBOY
Release: 2016-05-16 16:54:42
Original
1285 people have browsed it

jquery automatically fills the check box, that is, marks the check box (true), then obtains the list of checked options through ajax, and then marks the options in the list.

Copy code The code is as follows:

Drop-down box

select changes, triggering the function makemoduleSelected(), which is as follows:
Copy code The code is as follows:

//This event (onchange) is triggered when the template drop-down box changes.
function makemoduleSelected(){
clearAll('property');
var modtitlecode = $("#makemodule").val();
$.ajax({
url : ' indexStatisticsAction_getSelect.jsp',
data: { page:'clientindexStatistics.jsp',method:'get_subname_en',modtitlecode:modtitlecode},
success : function(result){
// Judge based on the result return information Whether the login is successful
var results = result.split(",");
//document.getElementById(results[i]).checked = true;
$(".indexStatistics").each( function(){
$(this).find("input").each(function(){
var tempVal = $(this).val();
for(var i=0; iif(tempVal == results[i]) $(this).attr("checked", true);
}
});
} ; Array, then traverse the tags under the tag
, and check the check box (true) when encountering relevant tags. The relevant code for indexStatisticsAction_getSelect.jsp is as follows:



Copy code

The code is as follows: //Get the template Corresponding indicator if(method.equals("get_subname_en")){ String modtitlecode = request.getParameter("modtitlecode"); if(modtitlecode.equals("------ ")) return;
String sql = sql2.replace("?modtitlecode?",modtitlecode);
sql = sql.replace("?userId?",userId);
System.out.println (sql);
StringBuffer subnames = new StringBuffer();
Db db = new Db();
try {
db.prepareQuery();
ResultSet rs = db.executeQuery( sql);
while (rs!=null && rs.next()) {
subnames.append(rs.getString("subname_en"));
subnames.append(",");
}
rs.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
db.endQuery();
}
PrintWriter pout = response.getWriter();
pout.write(subnames.toString().substring(0,subnames.length()-1));
pout.flush();
pout.close();
}

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template