The JQuery UI completes the drop-down list of auto-matching steps

Source: Internet
Author: User

1. First introduce the jquery UI-related JS, such as: Jquery-ui-1.10.4.js

2. Write JS

<Scripttype= "Text/javascript">$(function() {setautocomplete ();});/*Auto-Complete parts number*/functionSetautocomplete () {$ ('. Class_name'). each (function() {$ ( This). AutoComplete ({Source:"/admin/class_getclassnamelist.do",
Minimum number of user input minLength:4}); });}</Script>

3. Write Java code:

(1). Action:

/*** Get class list * @date July 11, 2017 pm 1:24:22 *@authorSongchunyan *@return     */     PublicString getclassnamelist () {Try {            //parameter, the default value is termString input = request.getparameter ("term"); List<String> partnolist =eltrainclassservice.getnmdyclassnamelist (input); String JSON=jsonutil.serialize (partnolist);  This. writehtml (JSON); return NULL; } Catch(dolexception e) {logger.error (E.getmessage (), E); returnhandledolexception (e); } Catch(Exception e) {logger.error (E.getmessage (), E); returnHandleException (e); }    }

(2). Service:

/*** Get class drop-down list * @date July 11, 2017 pm 1:26:42 *@authorSongchunyan *@paramInput *@return     * @throwsException*/     Public Staticlist<string> getnmdyclassnamelist (String input)throwsexception{dbbase DB=NULL; Try{db=Newdbbase (); returneltrainclassdao.getnmdyclassnamelist (db,input); } Catch(Exception e) {logger.error ("Getnmdyclassnamelist Error:" +e.tostring (), E); Throwe; } finally {            if(db! =NULL) {db.release (); }        }    }

3.dao:

/*** Get class drop-down list * @date July 11, 2017 pm 1:28:14 *@authorSongchunyan *@paramDB *@paramInput *@return     * @throwsException*/     Public StaticList<string> getnmdyclassnamelist (dbbase db, String input)throwsexception{StringBuffer SQL=NewStringBuffer (); Sql.append ("Select Train_class_uid,train_class_name from El_tms_offline_train_class etotc,tbl_research TR"); Sql.append ("WHERE Etotc.train_uid = Tr.train_uid"); Sql.append ("And Etotc.begin_time <= Now ()"); Sql.append ("and tr.isnmdy= ' Y '"); Sql.append ("and train_class_name like concat ('% ',?, '% ')"); Sql.append ("Limit 10");        Db.initps (Sql.tostring ()); Db.setpsstring (1, input); ResultSet RS=Db.executequery (); List<String> list =NewArraylist<string>();  while(Rs.next ()) {//cu = new Eltrainclass (); //Cu.settrainclassuid (rs.getstring ("Train_class_uid")); //Cu.settrainclassname (rs.getstring ("Train_class_name"));List.add (rs.getstring ("Train_class_name"));        } rs.close (); returnlist; }

The JQuery UI completes the drop-down list of auto-matching steps

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.