Dwr之util.js

前端之家收集整理的这篇文章主要介绍了Dwr之util.js前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
<%@ 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>My JSP 'index.jsp' starting page</title>
<script type="text/javascript" src="dwr/engine.js"></script>
<script type="text/javascript" src="dwr/util.js"></script>
<script type="text/javascript">
	var cityArraySimple = [ '北京','海口','乌鲁木齐' ];
	var cityArray = [ {
		name : '重庆',id : 'cq'
	},{
		name : '成都',id : 'cd'
	},{
		name : '大连',id : 'dl'
	} ];

	function fillSelect() {
		dwr.util.addOptions("select1",cityArraySimple);
		dwr.util.addOptions("select2",cityArray,"name");
		dwr.util.addOptions("select3","id","name");
	}

	function removeSelect() {
		dwr.util.removeAllOptions("select1");
		dwr.util.removeAllOptions("select2");
		dwr.util.removeAllOptions("select3");
	}
</script>
</head>

<body>
	数组:<select id="select1" style="width: 100px;"></select><br /> 
	数组(指定text):<select id="select2" style="width: 100px;"></select><br />
	数组(指定text和value):<select id="select3" style="width: 100px;"></select><br />
	<input type="button" value="填充下拉列表" onclick="fillSelect();">
	<input type="button" value="移除下拉列表" onclick="removeSelect();">
</body>
</html>
原文链接:https://www.f2er.com/ajax/166040.html

猜你在找的Ajax相关文章