2
This was a tricky one, but I figured it out for the reviews module that I am writing (possibly soon to be released).
First, you must understand that by putting a [] after the name of an input on a form, that makes it pass its value as an array. However, it also makes it difficult for javascript to see that element, so you want to start with the name of the list box NOT having the [].
1. go to:
http://javascript.internet.com/forms/form-swapper-2.html
and get the code (with javascript) for the menu swapper. This allows you to choose as many items as you want from one multiple select and move them to a second multiple select. I personally am using XOOPS 2.0.5, and I put the javascript here and below into xoops.js, since I use it on many pages. The definition of my second multiple select is as follows:
<select multiple size='10' name='review_categories' style='width:150'>
2. When you submit the form, you must include a little javascript to select all of the items in the second list, and make it pass the values as an array. Otherwise, they are not passed. I did htis with the following code:
<input type='submit' name='contents_submit' onClick='makeArray(this.form.review_categories)' value='Go'/>
where review_categories is the name of my second multiple select, and "makeArray" looks like this:
function makeArray(tBox)
{
tBox.name=tBox.name + "[]";
for (i=0;i<tBox.length;i++)
{
tBox.options[i].selected = true;
}
}
NOTE -- this is where the [] is added to the name of the input, making it pass the values as an array.
3. On the next page, you can access all the values of the input by using array syntax (review_categories[0], review_categories[1], etc., in my case).
Hope this helps.
--Rafi