jquery automatically fills the check box with the check box (true), then gets the list of check options by Ajax, and then the options in the list are typed.
Copy Code code as follows:
Dropdown box <select name= "Makemodule" id= "Makemodule" style= ' width:130px ' onchange= ' makemoduleselected ' () ' >
<option value= ' 1 ' >1</option>
</select>
Select Change, triggering function makemoduleselected (), the function is as follows:
Copy Code code as follows:
This event is triggered when the template Drop-down box changes (onchange).
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) {
Return information based on result to determine if login succeeded
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; i<results.length; i++) {
if (TempVal = = Results[i]) $ (this). attr ("Checked", true);
}
});
});
}
});
}
The function sends a request to indexstatisticsaction_getselect.jsp via Ajax, returns a string, separates the modified string into an array of strings, and then traverses the tag <div class= "Indexstatistics "> The label below, with the associated label, is ticked (true). The relevant code for INDEXSTATISTICSACTION_GETSELECT.JSP is as follows:
Copy Code code as follows:
//get template corresponding metric
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 ();
}