日期:2014-05-16 浏览次数:20388 次
?
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>处理列表--字符串数组</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <script type="text/javascript" src="js/util.js"></script> <script type="text/javascript"> var strArray = ['请选择一本书','Java','Hibernate','Spring',]; function add(){ dwr.util.addOptions("test",strArray); } function del(){ dwr.util.removeAllOptions("test"); } </script> </head> <body> <select id="test"></select> <input type="button" value="添加选项" onclick="add();"> <input type="button" value="删除选项" onclick="del();"> </body> </html>?处理列表--对象数组
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>处理列表--对象数组</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <script type="text/javascript" src="js/util.js"></script> <script type="text/javascript"> var objArray = [{name:'Java'}, {name:'Hibernate'}, {name:'Spring'}]; function add(){ dwr.util.addOptions("test",objArray,"name"); } function del(){ dwr.util.removeAllOptions("test"); } </script> </head> <body> <select id="test"></select> <input type="button" value="添加选项" onclick="add();"> <input type="button" value="删除选项" onclick="del();"> </body> </html>?处理列表--使用对象作为属性值的对象
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>处理列表--使用对象作为属性值的对象</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <script type="text/javascript" src="js/util.js"></script> <script type="text/javascript"> //定义一个每个属性值都是对象的对象 var objMap = { first:{book:'Java',price:'55'}, second:{book:'Hibernate',price:'66'}, third:{book:'Spring',price:'77'}, fourth:{book:'Struts2',price:'88'} }; function add(){ //对象数组为列表框添加列表项 //以第三