<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<%
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>My JSP 'a.jsp' starting page</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">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type='text/javascript' src='<%=path%>/dwr/util.js'>
</script>
<script type="text/javascript">
var strArr=['请选择一本图书','疯狂Java讲义','疯狂Ajax讲义','疯狂XML讲义'];
var strArr1=[{name:'疯狂Java讲义'},{name:'疯狂Ajax讲义',name:'疯狂XML讲义'}];
var strArr2=[{book:'疯狂Java讲义',price:'99'},{book:'疯狂Ajax讲义',price:'79'},{book:'疯狂XML讲义',price:'69'}];
var strArr3={name:"疯狂Java讲义",price:"99",publish:"电子工业出版社"};
var objMap={first:{book:'疯狂Java讲义',price:'99'},
second:{book:'疯狂Ajax讲义',price:'79'},
third:{book:'疯狂XML讲义',price:'69'},
fourth:{book:'轻量级Java EE企业应用实战',price:'89'},
fifth:{book:'经典Java EE企业应用实战',price:'89'}
};
function add(){
dwr.util.addOptions("test",strArr);
}
function del(){
dwr.util.removeAllOptions("test");
}
function add1(){
dwr.util.addOptions("test1",strArr1,'name');
}
function del1(){
dwr.util.removeAllOptions("test1");
}
function add2(){
dwr.util.addOptions("test2",strArr2,'book','price');
}
function del2(){
dwr.util.removeAllOptions("test2");
}
function add3(){
dwr.util.addOptions("test3",strArr3);
}
function del3(){
dwr.util.removeAllOptions("test3");
}
function add4(){
dwr.util.addOptions("test4",objMap,'price','book');
}
function del4(){
dwr.util.removeAllOptions("test4");
}
function init(){
dwr.util.useLoadingMessage("123");
}
</script>
</head>
<body οnlοad="init()">
<select id="test"></select>
<input type="button" value="添加选项" οnclick="add()">
<input type="button" value="删除选项" οnclick="del()">
<br>
<select id="test1"></select>
<input type="button" value="添加选项" οnclick="add1()">
<input type="button" value="删除选项" οnclick="del1()">
<br>
<select id="test2"></select>
<input type="button" value="添加选项" οnclick="add2()">
<input type="button" value="删除选项" οnclick="del2()">
<br>
使用对象添加选项:
<select id="test3"></select>
<input type="button" value="添加选项" οnclick="add3()">
<input type="button" value="删除选项" οnclick="del3()">
<br>
使用对象添加选项:
<select id="test4"></select>
<input type="button" value="添加选项" οnclick="add4()">
<input type="button" value="删除选项" οnclick="del4()">
</body>
</html>