Jag har ett problem där jag skapar två select-boxar (size>1 + multiple) och med hjälp av ett javascript för över val mellan de två boxarna. Två knappar [<<] och [>>] används för att "kasta" över valen mellan boxarna. När jag sen ska submitta dessa så vet jag inte hur jag ska fånga upp de nya värderna.Ta emot alla options från en select-box
Värderna lagras i en array i javascriptet. Ska jag kanske på nåt sätt föra över dessa arrayer till en ASP array och sen föra över den på något sätt i querystringen?
<code>
<%@ Language=VBScript %>
<% Option Explicit %>
<!-- #include virtual="/db_comp/adovbs.inc" -->
<!-- #include virtual="/db_comp/conn_start.inc" -->
<% Dim _
groups_array, _
computers_group_array, _
all_computers_array, _
Id, _
i
%>
<%
On Error Resume Next
Id = Request("Groups_listbox")
%>left
<%
'Get groups into array
Query = "dbo.WEB_dist_list_groups_sp"
RecSet.Open Query, Connect, adOpenStatic, adLockOptimistic
groups_array = RecSet.GetRows()
RecSet.Close
%>
<%
'Get computers for selected group into array
On Error Resume Next
Query = "dbo.WEB_dist_list_computers_group_sp " & Id
RecSet.Open Query, Connect, adOpenStatic, adLockOptimistic
computers_group_array = RecSet.GetRows()
RecSet.Close
%>
<%
'Get all computers into array
Query = "dbo.WEB_dist_list_computers_sp " & Id
RecSet.Open Query, Connect, adOpenStatic, adLockOptimistic
all_computers_array = RecSet.GetRows()
RecSet.Close
%>
<%
Set RecSet = Nothing
Connect.Close
Set Connect = Nothing
%>
<html>
<head>
<title></title>
<LINK rel="stylesheet" href="../style.css" type="text/css" />
<script language="Javascript">
<!--
function ClearList(OptionList, TitleName)
{ OptionList.length = 0;
}
function move(side)
{ var temp1 = new Array();
var temp2 = new Array();
var current1 = 0;
var current2 = 0;
var attribute;
//assign what select attribute treat as attribute1 and attribute2
if (side == "right")
{ attribute1 = document.rep.category_left;
attribute2 = document.rep.category_right;
}
else
{ attribute1 = document.rep.category_right;
attribute2 = document.rep.category_left;
}
//fill an array with old values
for (var i = 0; i < attribute2.length; i++)
{ temp1[current1++] = attribute2.options[i].value;
}
//assign new values to arrays
for (var i = 0; i < attribute1.length; i++)
{ if ( attribute1.options[i].selected )
{ temp1[current1++] = attribute1.options[i].value;
}
else
{ temp2[current2++] = attribute1.options[i].value;
}
}
//generating new options
for (var i = 0; i < temp1.length; i++)
{
attribute2.options[i] = new Option();
attribute2.options[i].value = temp1[i];
attribute2.options[i].text = temp1[i];
}
//generating new options
ClearList(attribute1,attribute1);
if (temp2.length>0)
{
for (var i = 0; i < temp2.length; i++)
{ attribute1.options[i] = new Option();
attribute1.options[i].value = temp2[i];
attribute1.options[i].text = temp2[i];
}
}
}
//-->
</script>
<script>
function print_value(value)
{
alert(value)
}
</script>
</head>
<body leftmargin=50 topmargin=50>
<form name="rep" method="post" action="admin_distgroup.asp">
<table>
<tr>
<td colspan=3>
<select class="select_box" size=1 name="Groups_listbox" onChange="javascript:document.rep.submit();">
<option selected value=""><pre><-- select --> </pre></option>
<%
For i = 0 To Ubound(groups_array,2)
if groups_array(0,i)=Id Then
Response.Write(" <option selected value=""" & groups_array(0,i) & """>" & groups_array(0,i) & "</option>" & vbCrLf)
else
Response.Write(" <option value=""" & groups_array(0,i) & """>" & groups_array(0,i) & "</option>" & vbCrLf)
END IF
Next
%>
</select>
</td>
</tr>
<tr>
<td>
<select class="select_box" name="category_left" multiple size="15" style="width=150px" width="150px">
<%
For i = 0 To Ubound(computers_group_array,2)
Response.Write(" <option value=""" & computers_group_array(0,i) & """>" & computers_group_array(0,i) & "</option>" & vbCrLf)
Next
%>
</select>
</td>
<td>
<input type="button" value=">>" onclick="move('right')"><br>
<input type="button" value="<<" onclick="move('left')">
</td>
<td>
<select name="category_right" multiple size="15" style="width=150px" width="150px">
<%
For i = 0 To Ubound(all_computers_array,2)
Response.Write(" <option value=""" & all_computers_array(0,i) & """>" & all_computers_array(0,i) & "</option>" & vbCrLf)
Next
%>
</select>
</td>
</tr>
</table>
</form>
</body>
</html>
</code>
Någon som har en bra idé hur detta ska gå till?