The jquery auto-fill check box is used to set the check box to true, obtain the check Option List through ajax, and then set the options in the list.
Copy codeThe Code is as follows:
Drop-down box <select name = "makemodule" id = "makemodule" style = 'width: 130px 'onchange = 'makemoduleselected () '>
<Option value = '1'> 1 </option>
</Select>
The select function changes and triggers the makemoduleSelected () function. The function is as follows:
Copy codeThe 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 <results. length; 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 labels under the label <div class = "indexStatistics">, if related tags are encountered, check (true ). The Code of indexStatisticsAction_getSelect.jsp is as follows:
Copy codeThe 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 ();
}