In the jquery auto-fill check box, the check box is marked with true_jquery.

Source: Internet
Author: User
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 ();
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.