Bendude14 Posted July 21, 2008 Share Posted July 21, 2008 I have this code <select name="copylist2" multiple size=10 onDblClick="Selectbox.copySelectedOptions(this.form.copylist2,this.form.copylist1,this.form.copysort.checked)"> and the submit button is called update and i am trying to retrieve it like so <?php if(isset($_POST['update'])) { $players = $_POST['copylist2']; echo $players; ?> It does process the code but i just get undefined index copylist2 error. Thanks Quote Link to comment Share on other sites More sharing options...
Bendude14 Posted July 22, 2008 Author Share Posted July 22, 2008 Can anyone help with this please? i know this would work if it was just a standard select box so it mush be something my javascript is doing to stop it posting? Thanks Quote Link to comment Share on other sites More sharing options...
xenophobia Posted July 22, 2008 Share Posted July 22, 2008 You can't really directly refer to your select box like this. Try this: <select name="copylist2" multiple size=10 onDblClick="Selectbox.copySelectedOptions(this,document.forms[0].copylist1,document.forms[0].copysort.checked)"> I assumed that you only have 1 form in your document. Using document.forms[0] referred to your current form. The 'this' was referred from the double-click event from the select box itself. So 'this' can represent the select box object. Quote Link to comment Share on other sites More sharing options...
lemmin Posted July 22, 2008 Share Posted July 22, 2008 He said the javascript part was working, I think. My guess is that Selectbox is defined in his javascript somewhere along with copySelectedOptions(). Can you show your code for copySelectedOptions()? Quote Link to comment Share on other sites More sharing options...
Bendude14 Posted July 23, 2008 Author Share Posted July 23, 2008 I have two list boxes and the javascript allows the names on the left to be moved by the user to the right and then when you click update i want to be able to process the information that was selected. I think it would be pointless for me to post the js because its a file i used from the javascript tool box and it is all in shorthand? if someone knows of any simpler scripts to get the same effect i would be happy to use them. thanks Ben Quote Link to comment Share on other sites More sharing options...
Bendude14 Posted July 25, 2008 Author Share Posted July 25, 2008 can anyone help with this? Maybe even a start to creating my own javascript to do this function would be must appreciated. Thanks Ben Quote Link to comment Share on other sites More sharing options...
lemmin Posted July 25, 2008 Share Posted July 25, 2008 A select object will only send one value to the POST so you will have to use javascript to send a bunch of values. Here is something to get you started: <script language="JScript"> function addItem(e) { var newOp = document.createElement('OPTION'); frmTest.selNew.add(newOp); newOp.innerText=e.innerText; newOp.name=e.name; newOp.value=e.value; var newHid = document.createElement('INPUT'); newHid.type="HIDDEN"; newHid.name=e.name; newHid.value=e.value; frmTest.appendChild(newHid); } </script> <form id="frmTest" method=POST action="test.php"> <select id="selOrig" name="selOrig" size=6 multiple onchange="addItem(document.getElementById(this.value))"> <option id="1" value="1" name="Item1">Item1 <option id="2" value="2" name="Item2">Item2 <option id="3" value="3" name="Item3">Item3 <option id="4" value="4" name="Item4">Item4 <option id="5" value="5" name="Item5">Item5 <option id="6" value="6" name="Item6">Item6 </select> <select id="selNew" name="selNew" size=6 multiple> </select> <input type=submit> </form> 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.