avivak1
asked on
Select from a listbox- move selected item to another listbox
Hi,
Does anyone out there have any code, or can direct me to the following senario.
I would like 2 listboxes.
One shows a list of users who have no access rights. Another is a listbox of who does.
If I double click on one item in one list it should jump to the other and vice versa.
If I choose the > arrow it should move selected item from left listbox to right
If I choose the < arrow it should move the selected item from right listbox to left
If I choose the >> arrow it should move all users from left listbox to right
If I choose the << arrow it should move all the users from right to left.
Thanks and here's a picture just to be sure
-------------------------- ---------- --------- -------------------------- ---------- ---------
- User A - > - User B -
- User C - - User E -
- User D - < - -
- User F - - -
- - >> - -
- - - -
- - << - -
-------------------------- ---------- --------- -------------------------- ---------- ---------- -
Does anyone out there have any code, or can direct me to the following senario.
I would like 2 listboxes.
One shows a list of users who have no access rights. Another is a listbox of who does.
If I double click on one item in one list it should jump to the other and vice versa.
If I choose the > arrow it should move selected item from left listbox to right
If I choose the < arrow it should move the selected item from right listbox to left
If I choose the >> arrow it should move all users from left listbox to right
If I choose the << arrow it should move all the users from right to left.
Thanks and here's a picture just to be sure
--------------------------
- User A - > - User B -
- User C - - User E -
- User D - < - -
- User F - - -
- - >> - -
- - - -
- - << - -
--------------------------
ASKER
Perfect, except for one thing.
I would like to double click on any of the options and it will go to the opposite box.
Thanks,
Aviva
I would like to double click on any of the options and it will go to the opposite box.
Thanks,
Aviva
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have a weird senario. Maybe you can help?
The first time I choose the options and click submit - they get entered into a table - no problem.
If I go back to the page with the choices in the list box - with the list box populated with the data that was entered If I click submit - the Request.Form does not recognise the values that are in the list
Review:
I put in User A, User B and User F into the Access List - works
When I come back
User A, B, and F are in the Access List Box
When I click submit Request.Form("Select2") has no data inside. (Using ASP etc)
The first time I choose the options and click submit - they get entered into a table - no problem.
If I go back to the page with the choices in the list box - with the list box populated with the data that was entered If I click submit - the Request.Form does not recognise the values that are in the list
Review:
I put in User A, User B and User F into the Access List - works
When I come back
User A, B, and F are in the Access List Box
When I click submit Request.Form("Select2") has no data inside. (Using ASP etc)
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
No that doesn't fix the issue. (but thanks!)
Also. There is no order so everything jumps all over the place depending on the different clicks
Also. There is no order so everything jumps all over the place depending on the different clicks
Hm, it's hard to tell without the source, but I'm guessing that when you're populating Select2 from your table/db, you're not assigning values to the options. A quick way to check would be to put A, B, and F into the Access List and submit. Return to the page, and then View Source on your browser. The options in Select2 should all have an attribute that says "value=SOMETHING" - if they don't, then either the ASP isn't populating the fields correctly, or the values aren't being stored into the table in the first place (maybe even both). Let me know if that doesn't make sense, and I'll try to explain. Hope that helps.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for all your help
Webby's answer was closest and of course mcouillard it's nice to see other options
Webby's answer was closest and of course mcouillard it's nice to see other options
<script language="JavaScript">
function dosubmit() {}
function deleteOption(object,index)
object.options[index] = null;
}
function addOption(object,text,valu
var defaultSelected = true;
var selected = true;
var optionName = new Option(text, value, defaultSelected, selected)
object.options[object.leng
}
function copySelected(fromObject,to
for (var i=0, l=fromObject.options.lengt
if (fromObject.options[i].sel
addOption(toObject,fromObj
}
for (var i=fromObject.options.lengt
if (fromObject.options[i].sel
deleteOption(fromObject,i)
}
}
function copyAll(fromObject,toObjec
for (var i=0, l=fromObject.options.lengt
addOption(toObject,fromObj
}
for (var i=fromObject.options.lengt
deleteOption(fromObject,i)
}
}
</script>
<html>
<head>
<title></title>
</head>
<body>
<form>
<table>
<tr>
<td><select name="select1" multiple size="7">
<option>User A </option>
<option>User B</option>
<option>User C</option>
<option>User D </option>
<option>User E</option>
<option>User F</option>
</select> </td>
<td><input type="button" value=" > "
onClick="copySelected(this
type="button" value=" < "
onClick="copySelected(this
<p><input type="button" value=">>"
onClick="if (document.images) copyAll(this.form.select1,
<p><input type="button" value="<<"
onClick="if (document.images) copyAll(this.form.select2,
<td><select name="select2" multiple size="7">
</select> </td>
</tr>
</table>
</form>
</body>
</html>