ShibSta Posted March 22, 2007 Share Posted March 22, 2007 Ok, I have 2 multiple selection lists. I am using javascript so that users can select items from list 1 and move them to list 2. When the user submits the form I need my php to get the values he has/she has in list 2... I have done printf($_POST['send_to']); and it only shows one value, even when multiple are selected. I read that I need to change it's name to list_2[] but if I add the brackets to the name my javascript quits working... Any suggestions? Here is my JS/HTML, my PHP is simply printf($_POST['send_to']); which prints the data in the array. <script type="text/javascript"> <!-- function compareOptionValues(a, b) { var sA = parseInt(a.value, 36); var sB = parseInt(b.value, 36); return sA - sB; } function compareOptionText(a, b) { var sA = parseInt(a.text, 36); var sB = parseInt(b.text, 36); return sA - sB; } function moveDualList(srcList, destList, moveAll) { if ((srcList.selectedIndex == -1) && (moveAll == false)) { return; } newDestList = new Array(destList.options.length); var len = 0; for (len = 0; len < destList.options.length; len++) { if (destList.options[len] != null) { newDestList[len] = new Option(destList.options[len].text, destList.options[len].value, destList.options[len].defaultSelected, destList.options[len].selected); } } for (var i = 0; i < srcList.options.length; i++) { if (srcList.options[i] != null && (srcList.options[i].selected == true || moveAll)) { newDestList[len] = new Option(srcList.options[i].text, srcList.options[i].value, srcList.options[i].defaultSelected, srcList.options[i].selected); len++; } } newDestList.sort(compareOptionValues); for (var j = 0; j < newDestList.length; j++) { if (newDestList[j] != null) { destList.options[j] = newDestList[j]; } } for (var i = srcList.options.length - 1; i >= 0; i--) { if (srcList.options[i] != null && (srcList.options[i].selected == true || moveAll)) { srcList.options[i] = null; } } } //--> </script> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td width="150" valign="top"> <select name="list" style="width:150px; height:100px; font-size:10px" multiple="multiple" size="6" ondblclick="moveDualList( this.form.list, this.form["send_to[]"][0], false )"> <!-- BEGIN user_list --> <option value='{UID}'>{UID} - {USERNAME}</option> <!-- END user_list --> </select> </td> <td width="150" align="center" valign="middle"> <input style="width: 120px; margin: 2px 0 2px 0; font-size: 10px;" type="button" value="Add Selected »" onclick="moveDualList( this.form.list, this.form["send_to[]"][0], false )"/> <input style="width: 120px; margin: 2px 0 2px 0; font-size: 10px;" type="button" value="« Remove Selected" onClick="moveDualList( this.form["send_to[]"][0], this.form.list, false )"/> <input style="width: 120px; margin: 2px 0 2px 0; font-size: 10px;" type="button" value="Add All »" onClick="moveDualList( this.form.list, this.form["send_to[]"][0], true )"/> <input style="width: 120px; margin: 2px 0 2px 0; font-size: 10px;" type="button" value="« Remove All" onClick="moveDualList( this.form["send_to[]"][0], this.form.list, true )"/> </td> <td valign="top"> <select name="send_to[]" style="width:150px; height:100px; font-size:10px" multiple="multiple" size="6" onDblClick="moveDualList( this.form["send_to[]"][0], this.form.list, false )"> </select> </td> </tr> </table> I did post this in the PHP section, I wasn't really thinking that it had more to do with JS... (Braindead. Sorry.) Quote Link to comment Share on other sites More sharing options...
emehrkay Posted March 23, 2007 Share Posted March 23, 2007 do print_r($_POST['send_to']); and see what is returned or even echo it then go from there Quote Link to comment Share on other sites More sharing options...
ShibSta Posted March 23, 2007 Author Share Posted March 23, 2007 Please read the post before responding. "I have done printf($_POST['send_to']); and it only shows one value," Quote Link to comment Share on other sites More sharing options...
fenway Posted March 23, 2007 Share Posted March 23, 2007 You haven't properly quoted your JS event handlers -- you have doubles within doubles. Quote Link to comment Share on other sites More sharing options...
ShibSta Posted March 23, 2007 Author Share Posted March 23, 2007 I have tried several variations of quotes, I cannot get it to work. I am new to javascript and normally stick to PHP. Could you please show me how it needs edited as I tend to be more of a visual learner... It seems like the quotes would be a logical answer to the issue but I cannot get it working properly... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.