如何在jsp页面中实现下拉菜单的功能
如题,想在jsp web中实现一个下拉菜单的功能,求前辈教我
[解决办法]
jquery
[解决办法]
额 js jquery
[解决办法]
去网上下载一个吧。这种列子有很多的。
[解决办法]
http://www.miniui.com/demo/#src=combobox/combobox.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>ComboBox 下拉选择框</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" /><link href="../demo.css" rel="stylesheet" type="text/css" />
<script src="../../scripts/boot.js" type="text/javascript"></script>
</head>
<body>
<h1>ComboBox 下拉选择框 </h1>
<h4>单选</h4>
<input id="combo1" class="mini-combobox" style="width:150px;" textField="text" valueField="id" emptyText="请选择国家"
url="../data/countrys.txt" value="cn" required="true" allowInput="true" showNullItem="true" nullItemText="请选择..."/>
<br /><br />
<input type="button" value="setValue" onclick="setValue()"/>
<input type="button" value="getValue" onclick="getValue()"/>
<input type="button" value="disable" onclick="disable()"/>
<input type="button" value="enable" onclick="enable()"/>
<h4>多选 + 多列</h4>
<div id="combobox2" class="mini-combobox" style="width:250px;" popupWidth="400" textField="text" valueField="id"
url="../data/countrys.txt" value="cn,usa" multiSelect="true" showClose="true" oncloseclick="onCloseClick" >
<div property="columns">
<div header="ID" field="id"></div>
<div header="国家" field="text"></div>
</div>
</div>
<h4>限制输入下拉数据</h4>
<input id="combobox3" class="mini-combobox" style="width:150px;" textField="text" valueField="id"
url="../data/countrys.txt" value="cn" showNullItem="true" required="true" allowInput="true"
onvalidation="onComboValidation"
/>
<input type="button" value="getValue" onclick="getValue2()"/>
<script type="text/javascript">
function setValue() {
var obj = mini.get("combo1");
obj.setValue("usa");
}
function getValue() {
var obj = mini.get("combo1");
alert(obj.getValue() +":"+ obj.getText());
}
function enable() {
var obj = mini.get("combo1");
obj.enable();
}
function disable() {
var obj = mini.get("combo1");
obj.disable();
}
function getValue2() {
var obj = mini.get("combobox3");
alert(obj.getValue() + ":" + obj.getText());
}
function onComboValidation(e) {
var items = this.findItems(e.value);
if (!items
[解决办法]
items.length == 0) {
e.isValid = false;
e.errorText = "输入值不在下拉数据中";
}
}
function onCloseClick(e) {
var obj = e.sender;
obj.setText("");
obj.setValue("");
}
</script>
<div class="description">
<h3>Description</h3>
<p>ComboBox显示一个下拉列表选择框。下拉框支持多列显示。
</p>
<p>valueField是值字段;textField是文本字段。</p>
</div>
</body>
</html>