<!--#include file="BCONN.asp"-->
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<LINK rel="stylesheet" type="text/css" href="Css.css">
<title>方案设计</title>
</head><body>
<form method="post" name="myform" action="6.asp">
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
sortitems = 1; // Automatically sort items within lists? (1 or 0) function move(fbox,tbox) {
for(var i=0; i<fbox.options.length; i++) {
if(fbox.options[i].selected && fbox.options[i].value != "") {
var no = new Option();
no.value = fbox.options[i].value;
no.text = fbox.options[i].text;
tbox.options[tbox.options.length] = no;
fbox.options[i].value = "";
fbox.options[i].text = "";
}
}
BumpUp(fbox);
if (sortitems) SortD(tbox);
} function moveall(fbox,tbox) {
for(var i=0; i<fbox.options.length; i++) {
if(fbox.options[i].value != "") {
var no = new Option();
no.value = fbox.options[i].value;
no.text = fbox.options[i].text;
tbox.options[tbox.options.length] = no;
fbox.options[i].value = "";
fbox.options[i].text = "";
}
}
BumpUp(fbox);
if (sortitems) SortD(tbox);
}
function BumpUp(box) {
for(var i=0; i<box.options.length; i++) {
if(box.options[i].value == "") {
for(var j=i; j<box.options.length-1; j++) {
box.options[j].value = box.options[j+1].value;
box.options[j].text = box.options[j+1].text;
}
var ln = i;
break;
}
}
if(ln < box.options.length) {
box.options.length -= 1;
BumpUp(box);
}
} function SortD(box) {
var temp_opts = new Array();
var temp = new Object();
for(var i=0; i<box.options.length; i++) {
temp_opts[i] = box.options[i];
} for(var x=0; x<temp_opts.length-1; x++) {
for(var y=(x+1); y<temp_opts.length; y++) {
if(temp_opts[x].text > temp_opts[y].text) {
temp = temp_opts[x].text;
temp_opts[x].text = temp_opts[y].text;
temp_opts[y].text = temp;
temp = temp_opts[x].value;
temp_opts[x].value = temp_opts[y].value;
temp_opts[y].value = temp;
}
}
} for(var i=0; i<box.options.length; i++) {
box.options[i].value = temp_opts[i].value;
box.options[i].text = temp_opts[i].text;
}
}
// End -->
</script>
<table width="90%" cellpadding="0" cellspacing="0" align="center">
<tr>
<td align="center"><fieldset style="width:460" align="center">
<legend> 科目选择</legend>
<table width="479" border="0">
<tr>
<td width="200">
<select name="list1" size="10" multiple class="title2" style="width:200px">
<%
Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs = Server.CreateObject("ADODB.Recordset")
Conn.open Connstr
Sql = "RptItemList "
Set Rs = conn.execute(Sql)
If Rs.Bof or Rs.Eof Then
Response.write "无记录"
Else
Do While Not Rs.eof
%>
<option value='<%=Rs("FItemNum")%>'><%=Rs("FItemName")%></option>
<%
Rs.Movenext
Loop
End if
Set Rs=nothing
%>
</select>
</td>
<td width="65">
<input type="button" value=" => " onClick="move(this.form.list1,this.form.list2)" name="B1">
<br>
<input type="button" value=" <= " onClick="move(this.form.list2,this.form.list1)" name="B2">
<br>
<input type="button" value=" =>> " onClick="moveall(this.form.list1,this.form.list2)" name="B3">
<br>
<input type="button" value=" <<= " onClick="moveall(this.form.list2,this.form.list1)" name="B4">
</td>
<td width="200"><select multiple size="10" name="list2" style="width:200px">
</select></td>
</tr>
</table>
</fieldset></td>
</tr>
</table>
</form> </body>
</html>上面的JS代码可以实现将左边的数据单个,多个,全部,移到右边,但是现在我不知道要如何才可以取到动态移到右边的数据值,请高手修改一下这个JS,能生成一个可以传到下一页的值~~
下面的这段代码可以作参考,他可以动态产生这个值,但是无法实现全选:<!--#include file="BCONN.asp"-->
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<LINK rel="stylesheet" type="text/css" href="Css.css">
<title>方案设计</title>
</head><body>
<form method="post" name="myform" action="6.asp">
<table width="90%" cellpadding="0" cellspacing="0" align="center">
<tr>
<td align="center"><fieldset style="width:460" align="center">
<legend> 科目选择</legend>
<table width="479" border="0">
<tr>
<td >
<select style="width:220px;" multiple name="left" size="8"
ondblclick="moveOption(document.getElementById('left'), document.getElementById('right'))">
<%
Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs = Server.CreateObject("ADODB.Recordset")
Conn.open Connstr
Sql = "RptItemList "
Set Rs = conn.execute(Sql)
If Rs.Bof or Rs.Eof Then
Response.write "无记录"
Else
Do While Not Rs.eof
%>
<option value='<%=Rs("FItemNum")%>'><%=Rs("FItemName")%></option>
<%
Rs.Movenext
Loop
End if
Set Rs=nothing
%>
</select>
</td>
<td>
<input type="button" value=" => " onClick="moveOption(document.getElementById('left'),document.getElementById('right'))">
<br>
<input type="button" value=" <= " onClick="moveOption(document.getElementById('right'),document.getElementById('left'))">
<br>
</td>
<td><select style="width:220px" multiple name="right" size="8" ondblclick="moveOption(document.getElementById('right'), document.getElementById('left'))"></select></td>
</tr>
</table>
<p>
<input type="text" name="result" id="result" size="40" value="" /></p>
<p><input name="Submit" type="submit" value="提交"></p>
</fieldset></td>
</tr>
</table>
</form>
<script language="JavaScript">
<!--
function moveOption(e1, e2){
for(var i=0;i<e1.options.length;i++){
if(e1.options[i].selected){
var e = e1.options[i];
e2.options.add(new Option(e.text, e.value));
e1.remove(i);
i=i-1
}
}
document.getElementById('result').value=getvalue(document.getElementById('right'));
}
function getvalue(geto){
//var allvalue = "";
//for(var i=0;i<geto.options.length;i++){
// allvalue +=geto.options[i].value + ",";
//}
var resultArray = new Array();
for(var i=0;i<geto.options.length;i++){
resultArray.push(geto.options[i].value);
}
return resultArray.join();
}
//-->
</script>
</form> </body>
</html>
JS不懂,所以求高人帮助了~~~
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货