这个如何实现?? 我就想实现增加或者删除某个用户,用这种形式 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 就是左边一个框 可能是textarea 右边也有一个,中间有> 和 < 比如左边的框里有几行 每行是一个用户, 选中他 然后点一下> 这个用户就被移动到到右边框里现在我要在一个JSP页面里实现 该怎么实现呢? 你说的实现方式都是才用javaScript,你去找这方面的资料看看吧, 建两个select框id分别为“DropDownList1”,“DropDownList2”,然后利用下面脚本试试 function moveRight() { var source = document.getElementById("DropDownList1"); var purpose = document.getElementById("DropDownList2"); if (source.selectedIndex > -1) { var size = source.length; for (var i = 0;i < size; i++) { if (source.options[i].selected) { purpose.options.add(new Option(source[i].text,source[i].value)); source.options.remove(i); i = i -1; size = size - 1; } } } else { alert("请选择要移动的城市!"); return false; } } function moveLeft() { var source = document.getElementById("DropDownList2"); var purpose = document.getElementById("DropDownList1"); if (source.selectedIndex > -1) { var size = source.length; for (var i = 0;i < size; i++) { if (source.options[i].selected) { purpose.options.add(new Option(source[i].text,source[i].value)); source.options.remove(i); i = i -1; size = size - 1; } } } else { alert("请选择要移动的城市!"); return false; } } function moveUp(){ var source = document.getElementById("DropDownList2"); if (source.selectedIndex > -1) { var size = source.length; var tempText = ""; var tempValue = ""; for (var i = 0;i < size; i++) { if (source.options[i].selected) { //alert(source.options[i].index); if (source.options[i].index != 0) { tempText = source.options[i].text; tempValue = source.options[i].value; source.options[i].text = source.options[i-1].text; source.options[i].value = source.options[i-1].value; source.options[i-1].text = tempText; source.options[i-1].value = tempValue; source.options[i].selected = false; source.options[i-1].selected = true; } else { alert("已经到达最上端!"); return false; } } } } else { alert("请选择要移动的城市!"); return false; } } function moveDown(){ var source = document.getElementById("DropDownList2"); if (source.selectedIndex > -1) { var size = source.length; var tempText = ""; var tempValue = ""; for (var i = size-1;i > -1; i--) { if (source.options[i].selected) { //alert(source.options[i].index); if (source.options[i].index != size-1) { tempText = source.options[i].text; tempValue = source.options[i].value; source.options[i].text = source.options[i+1].text; source.options[i].value = source.options[i+1].value; source.options[i+1].text = tempText; source.options[i+1].value = tempValue; source.options[i].selected = false; source.options[i+1].selected = true; } else { alert("已经到达最下端!"); return false; } } } } else { alert("请选择要移动的城市!"); return false; } } 代码启动内置Tomcat服务器 (学习struts2标签)Expression parameters.formName is undefined <data valueType= row= ..... /> 属性含义 JSP页面间传值 输入框光标返回问题 关于不刷新页面用JS显示的问题 哪位高手,使用JSP如果实现如下效果? 请教:jsp如何写模糊查询? 怪问题,很多人都不知道,郁闷 请问java.sql.SQLException: Before start of result set什么意思? javascript 的相关问题。~~~ 正则表达式 匹配符
比如左边的框里有几行 每行是一个用户, 选中他 然后点一下> 这个用户就被移动到到右边框里
现在我要在一个JSP页面里实现 该怎么实现呢?
var source = document.getElementById("DropDownList1");
var purpose = document.getElementById("DropDownList2");
if (source.selectedIndex > -1) {
var size = source.length;
for (var i = 0;i < size; i++) {
if (source.options[i].selected) {
purpose.options.add(new Option(source[i].text,source[i].value));
source.options.remove(i);
i = i -1;
size = size - 1;
}
}
} else {
alert("请选择要移动的城市!");
return false;
}
}
function moveLeft() {
var source = document.getElementById("DropDownList2");
var purpose = document.getElementById("DropDownList1");
if (source.selectedIndex > -1) {
var size = source.length;
for (var i = 0;i < size; i++) {
if (source.options[i].selected) {
purpose.options.add(new Option(source[i].text,source[i].value));
source.options.remove(i);
i = i -1;
size = size - 1;
}
}
} else {
alert("请选择要移动的城市!");
return false;
}
}
function moveUp(){
var source = document.getElementById("DropDownList2");
if (source.selectedIndex > -1) {
var size = source.length;
var tempText = "";
var tempValue = "";
for (var i = 0;i < size; i++) {
if (source.options[i].selected) {
//alert(source.options[i].index);
if (source.options[i].index != 0) {
tempText = source.options[i].text;
tempValue = source.options[i].value;
source.options[i].text = source.options[i-1].text;
source.options[i].value = source.options[i-1].value;
source.options[i-1].text = tempText;
source.options[i-1].value = tempValue;
source.options[i].selected = false;
source.options[i-1].selected = true;
} else {
alert("已经到达最上端!");
return false;
}
}
}
} else {
alert("请选择要移动的城市!");
return false;
}
}
function moveDown(){
var source = document.getElementById("DropDownList2");
if (source.selectedIndex > -1) {
var size = source.length;
var tempText = "";
var tempValue = "";
for (var i = size-1;i > -1; i--) {
if (source.options[i].selected) {
//alert(source.options[i].index);
if (source.options[i].index != size-1) {
tempText = source.options[i].text;
tempValue = source.options[i].value;
source.options[i].text = source.options[i+1].text;
source.options[i].value = source.options[i+1].value;
source.options[i+1].text = tempText;
source.options[i+1].value = tempValue;
source.options[i].selected = false;
source.options[i+1].selected = true;
} else {
alert("已经到达最下端!");
return false;
}
}
}
} else {
alert("请选择要移动的城市!");
return false;
}
}