文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>AJAX(1)--自动提示

AJAX(1)--自动提示

时间:2006-05-31  来源:dxadnwfn



ajax-autocomplete.jsp
<%@ page contentType="text/html;charset=utf-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>AJAX(1)-自动提示</title>     <form name="autofillform" action="#" method="get"> <input type="hidden" name="action" value="lookupbyname"/> <table border="0" cellpadding="5" cellspacing="0"> <tr> <td><b>Employee Name:</b></td> <td> <input type="text" size="20" id="complete-field" name="id" onkeyup="doCompletion();"> </td> <td align="left"> <input id="submit_btn" type="Submit" value="Lookup Employee"> </td> </tr> <tr><td id="auto-row" colspan="3">&nbsp;<td/>&nbsp;</tr> </table> </form> <div style="position: absolute; top:170px;left:140px" id="menu-popup"> <table id="names" bgcolor="#FFFAFA" border="1" bordercolor="black" cellspacing="0" cellpadding="0"/> </div> </html>
J2EEAjaxService.java
public class J2EEAjaxService { public static final int API_SIZE = 20; public List filterEmployees(String id) { List filteredEmployees = new LinkedList(); List employees = EmployeeBean.employees(); id = id.toLowerCase(); for (int i = 0; i < employees.size(); i++) { EmployeeBean employeebean = (EmployeeBean)employees.get(i); if((employeebean.getFirstName().toLowerCase().startsWith(id) || employeebean.getLastName().toLowerCase().startsWith(id)) && !id.equals("")) { filteredEmployees.add(employeebean); } } return filteredEmployees; } public String[] filterJavaAPI(String input, int size) { String[] list = new JavaAPISearcher().filter(input, size); return list; } }
EmployeeBean.java
public class EmployeeBean { public static List employees = new ArrayList(); public static List employees() { if (employees.size() > 0) return employees; employees.add(new EmployeeBean("1", "Greg", "Murray")); employees.add(new EmployeeBean("2", "Greg", "Murphy")); employees.add(new EmployeeBean("3", "George", "Murphy")); employees.add(new EmployeeBean("4", "George", "Murray")); employees.add(new EmployeeBean("5", "Peter", "Jones")); employees.add(new EmployeeBean("6", "Amber", "Jones")); employees.add(new EmployeeBean("7", "Amy", "Jones")); employees.add(new EmployeeBean("8", "Bee", "Jones")); employees.add(new EmployeeBean("9", "Beth", "Johnson")); employees.add(new EmployeeBean("10", "Cindy", "Johnson")); employees.add(new EmployeeBean("11", "Cindy", "Murphy")); employees.add(new EmployeeBean("12", "Duke", "Hazerd")); return employees; } public EmployeeBean(String s, String s1, String s2) { id = s; firstName = s1; lastName = s2; } private String id; private String firstName; private String lastName; getter/seter... }

属性文件
buffalo-service.properties
ajaxService=net.buffalo.demo.ajax.J2EEAjaxService
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载