True! I actually had that very solution working at one point. I was unhappy with the method though. First there's the visual aspect - seeing the list go black made me unhappy (developer-perfectionist :o).
Also, one of the main reasons I had difficulty was that I couldn't adapt the JavaScript routines I had written to work with the array that is normally used with multi-select <select> tags.
In my current implementation, I use "multiple" in my <select> tag to allow the user to select multiple users to shift from one list to another. I don't however have the select named as an array --> <select name=list1[] multiple>. Instead I use --> <select name=list1 multiple>.
So I have <input type="hidden" name="member_list"> burried there in my form, and the following JavaScript to set its values.
( The hidden <input> field is called "member_list". I have defined some JavaScript vars under my form:
<script language="JavaScript">
var left_list = document.myform.list1;
var right_list = document.myform.list2;
var commit_button = document.myform.submit_button;
var member_list = document.my_form.member_list;
</script>
)
Then I have the following JavaScript which is called with the submit button's 'onClick' event:
function populate_member_list(){
members="";
num_items = right_list.length;
for(i=0;i < num_items;i++){
if (i < num_items-1){
members = members + right_list.options[i].text + ",";
} else members = members + right_list.options[i].text;
}
member_list.value=members;
}
Just for the sake of completeness, here is one of my list member transfer JavaScripts. The other one is called "right_to_left()" of course!
function left_to_right() {
commit_button.disabled=false;
for ( i=0; i<left_list.length ; i++){
if (left_list.options[i].selected == true ) {
right_list.options[right_list.length]= new Option(left_list.options[i].text);
}
}
for ( i = (left_list.length -1); i>=0; i--){
if (left_list.options[i].selected == true ) {
left_list.options[i] = null;
}
}
}
Thanks for your feedback! I really appreciate it. 🙂
And apologies to all for all the JavaScript! It is PHP related, I promise!