Note that there are some explanatory texts on larger screens.

plurals
  1. POGet selected values in a dual listbox PHP
    text
    copied!<p>I want to output the selected values from the right hand listbox. However I am not successful in getting the values of selected values. The error returns from the submit function of js. Can anyone tell me why does it return: </p> <pre><code>An object doesn't support this property </code></pre> <p>in the submit function? How can i get the values.. will i use ajax or just returned value in PHP?</p> <pre><code> &lt;form name="frmListSubmit" method="post" id="myform" onsubmit="return submit()"&gt; &lt;table cellpadding="2" cellspacing="0" border="0" id="tblMain" class="edit"&gt; &lt;tr valign="top"&gt; &lt;td&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/td&gt; &lt;td&gt; &lt;SELECT id="s" size="10" name="source" multiple&gt; &lt;?php while($row = mysql_fetch_assoc($getEmployeeList)) { ?&gt; &lt;option name="list" value="&lt;?php echo $row['id'];?&gt;"&gt;&lt;?php echo $row['name']; ?&gt;&lt;/option&gt; &lt;?php } ?&gt; &lt;/td&gt; &lt;/SELECT&gt; &lt;td valign="center"&gt; &lt;a href="#" onclick="listbox_moveacross('s', 'd')" style="color:#FFF"&gt;&amp;gt;&amp;gt;&lt;/a&gt; &lt;a href="#" onclick="listbox_moveacross('d', 's')" style="color:#FFF"&gt;&amp;lt;&amp;lt;&lt;/a&gt; &lt;/td&gt; &lt;td&gt; &lt;SELECT id="d" size="10" name="destination" multiple&gt; &lt;option name="list" value=""&gt;&amp;nbsp;&lt;/option&gt; &lt;/SELECT&gt; &lt;input type="submit" name="submit" value="submit" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; </code></pre> <p>and here is the javascript code:</p> <pre><code>function listbox_moveacross(sourceID,destID) { var src=document.getElementById(sourceID); var dest=document.getElementById(destID); for(var count=0;count&lt;src.options.length;count++) { if(src.options[count].selected==true) { var option=src.options[count]; var newOption=document.createElement("option"); newOption.value=option.value; newOption.text=option.text; newOption.selected=true; try { dest.add(newOption,null);src.remove(count,null); } catch(error) { dest.add(newOption);src.remove(count); } count--; } } } function listbox_selectall(listID,isSelect) { var listbox=document.getElementById(listID); for(var count=0;count&lt;listbox.options.length;count++) { istbox.options[count].selected=isSelect; } } function submit() { listbox_selectall('d', true); return true; } </code></pre> <p>I have something like this in PHP and it returns only one ID after submission.</p> <pre><code>if(isset($_POST['submit'])) { echo $_POST['destination']; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload