Jump to content

2 comboboxes


Akasha

Recommended Posts

Hello i have 2 multiple comboboxesthe first one contains people that are on the project.The second one contains the other members that are not on the project.Between the 2 comboboxes there are 2 buttons with the value < > When a person selects a person en presses < the selected person from combobox 2 must go to combobox 1When a person selects a person en presses > the selected person from combobox 1 must go to combobox 2I hope its clear what i wantdoes anyone has a code for this or somethingthanks in advance --------------------Greetz Akasha Valo aka Leandrawe are so young, our lives has just begunbut already we're considering, escape from this worldand we've waited for so long, for this moment to comewe're so anxious to be together.... together in death
Pollux  Mar 3 2006, 10:59 AM Post #2  Easiest way is to do that with javascript. You'll need to write 2 functions: moveLeft() and moveRight() which are called onclick of the '<' and '>' buttons respectively.The functions will need to retrieve all the selected items from one select box and add them to the DOM in the other. You'll need to look up how to retrieve multiple values from a select, and also how to dynamically add items to a select box. Neither are very difficult so if you get stuck, or aren't sure where to start, post again in the javascript forum and I (or someone else) will give you a hand. 
Link to comment
Share on other sites

The first as well as the second are filled dynamically by a query out a database.So i gues i need to create 2 arrays fill these with the query and fill the comboboxes with the array.but is it possible to just delete a item out of an array. Because i think a gap is created and that is not the intention.

Link to comment
Share on other sites

ok he deletes from one combobox and add something to the otherbut he is only adding blank thingies :)this is my java script

function move(from,to){  var x = document.getElementById(from)  to.options[to.options.length] = new Option(x.text, x.value);    x.remove(x.selectedIndex)}

Link to comment
Share on other sites

already found the problem :) :) also for multiple selects

function move(from,to){  for (var i=0; i < from.options.length; i++) {  var x = from.options[i];  if (x.selected) {    to.options[to.options.length] = new Option(x.text, x.value, false, false);          	}  } for (var i=(from.options.length-1); i>=0; i--) {  var o = from.options[i];  if (o.selected) {  	from.options[i] = null;  	}  }}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...