I'm trying to do a basic set of functions that will copy values from one multiple select to another multiple select. Here is the Javascript:
And here's some sample HTML:
The problem is that, when the PHP file does a count() of $_POST['addOwners'], it returns 0 if I add or remove any users. Any idea why?
Code:
function addOwners(addSelect, delSelect) { var add = document.getElementById(addSelect); var del = document.getElementById(delSelect); // Get the names in the "users to be added" selection and the current owners select var addOwners = add.options; var curOwners = del.options; // If a user is selected, add that user to the current owners list var i = 0; for (i = 0; i < addOwners.length; i++) { // If the object exists if (addOwners) { if(addOwners.selected) { var index = curOwners.length; curOwners[index] = new Option(addOwners.text, addOwners.value, false); // Remove the reference to this object addOwners = null; // We set i to be -1 so that the for loop will increment it to 0 and // re-iterate through the list i = -1; } } } }
And here's some sample HTML:
Code:
<table style="width: 100%"> <tr> <td style="width: 40%; text-align: right"> <select name="delOwners[ ]" id="selectNonowners" style="height: 7em;" MULTIPLE> <option value="2">afrotiff</option> <option value="1">jrh3k5</option> <option value="7">mkb</option> <option value="6">Omega6744</option> <option value="4">tnb324</option> <option value="3">TootSweetie85</option> </select> </td> <td style="width: 20%; text-align: center"> <span class="smalltext"> <input type="button" onClick="javascript:addOwners('selectNonowners', 'selectOwners')" value="Add >>" /> <p /> <input type="button" onClick="javascript:delOwners('selectNonowners', 'selectOwners')" value="<< Remove" /> </span> </td> <td style="width: 40%; text-align: left"> <select name="addOwners[ ]" id="selectOwners" style="height: 7em;" MULTIPLE> </select> </td> </tr> </table>
The problem is that, when the PHP file does a count() of $_POST['addOwners'], it returns 0 if I add or remove any users. Any idea why?
the idiot is the person who follows the idiot and your not following me your insulting me your following the path of a idiot so that makes you the idiot - LC Tusken