DWR操作下拉列表框例子

<%@ 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>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值