jquery automatically fills the check box to make the check box true

Source: Internet
Author: User
Tags stringbuffer

The

 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 played

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.   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 ( , this function:  the following code:///////(onchange) When the template dropdown 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) { //Based on result return information to determine whether login success   var results = Result.split (","); //document.getelementbyid (results[i)). Checked = true;  $ (". Indexstatistics "). each (function () {  $ (a). 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 uses Ajax to Indexstatisticsaction_ Getselect.jsp makes a request, returns a string, separates the modified string into an array of strings, and then loops through the label <div class= "Indexstatistics" > The label below and encounters the associated label (TRUE). Indexstatisticsaction_getselect.jsp's code is as follows:  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.pr Eparequery ();  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 (); }&nbsP PrintWriter pout = Response.getwriter ();  pout.write (subnames.tostring (). substring (0,subnames.length ()-1));   Pout.flush ();  pout.close (); }   

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.