The jquery auto-fill check box is used to set the check box to true. Then, you can use ajax to obtain the check list, and then add the options in the list to the jquery auto-fill check box, that is, check the box (true), obtain the check Option List through ajax, and then set the options in the list.
The Code is as follows:
Drop-down list 1
The select function changes and triggers the makemoduleSelected () function. The function is as follows:
The Code is as follows:
// This event (onchange) is triggered when the template drop-down box is changed ).
Function makemoduleSelected (){
ClearAll ('properties ');
Var modtitlecode = $ ("# makemodule"). val ();
$. Ajax ({
Url: 'indexstatisticsaction _ getSelect. jsp ',
Data: {page: 'clientindexstatistics. jsp ', method: 'Get _ subname_en', modtitlecode: modtitlecode },
Success: function (result ){
// Determine whether the logon is successful based on the result returned.
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 If (tempVal = results [I]) $ (this). attr ("checked", true );
}
});
});
}
});
}
This function sends a request to indexStatisticsAction_getSelect.jsp in ajax mode, returns a string, splits the modified string into a string array, and then traverses the tag
The following tags are checked (true) When related tags are encountered ). The Code of indexStatisticsAction_getSelect.jsp is as follows:
The Code is as follows:
// Obtain the metrics corresponding to the template
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.exe cuteQuery (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 ();
}