help with javascript function that selects all options in a <select multiple> on submit


I want all the options selected when the user clicks the submit button so that in PHP i can get all the values that were in the list without the user having to highlight them.


foreach ($_POST['right'] as $selectedOption) {

echo $selectedOption."<br>";




function selectAllOptions(obj) {

if (!hasOptions(obj)) { return; }

for (var i=0; i<[url removed, login to view]; i++) {

[url removed, login to view][i].selected = true;




<form name='dealerform' id='dealerform' method=post action='[url removed, login to view]' onsubmit='selectAllOptions(right)'>

Offices -------------------------------------------------------------------> Selected Offices<br />

<table border="0" cellpadding="3" cellspacing="0"><tr><td>

<select multiple style='width: 277px;' size="20" name="left[]">


$sql="select officeid,name from office where officeid not in (select officeid from office_dealer) order by name";

if (!$result = $mysqli->query($sql)) { echo "Error selecting offices"; exit; }

while ($row = $result->fetch_assoc()) {

echo "<option value='{$row['officeid']}'>{$row['name']}</option>";




<td align="center" valign="middle">

<input type="Button" value="Add >>" style="width:100px" onClick="SelectMoveRows([url removed, login to view]['left[]'],[url removed, login to view]['right[]'])"><br><br>

<input type="Button" value="<< Remove" style="width:100px" onClick="SelectMoveRows([url removed, login to view]['right[]'],[url removed, login to view]['left[]'])"></td><td>

<select multiple style='width: 277px;' size="20" name="right[]">


<br /><br /><input type='submit' tabindex=999 value='Submit'>


Skills: HTML, Javascript, PHP

See more: convert a psd design to html with javascript function to select and unselect all checkboxes, jquery select multiple options drop, select multiple file time folder asp net javascript, select multiple files javascript photoshop, oscommerce select multiple options, multiple select list value retain reload javascript php, submit multiple form script java javascript, call select sql javascript function, select multiple file choose file dialog javascript, select multiple category php, joomla main_menu javascript function, multiple upload progress bar javascript php, Javascript function, cartweaver multiple product options

Project ID: #14070521

Awarded to:


Hi, i have read the project description, it’s perfectly match with my expertise. I believe i can do it with exact requirements within time and cost. I do not have any issue as i have done a lot of projects in Javascri More

$15 USD in 0 days
(26 Reviews)

18 freelancers are bidding on average $17 for this job


Hi I can do this for you. Hire me please. Thank you! .

$15 USD in 10 days
(504 Reviews)

MM. Hi, I will select all options in a select. Please let me know more about it . So that we can take things forward. Thanks.

$20 USD in 10 days
(270 Reviews)
$15 USD in 0 days
(80 Reviews)
$15 USD in 0 days
(77 Reviews)

- I'm a professional developer & designer that can work with: * PHP * HTML5 * CSS3 * jQuery * Javascript * Codeiginiter * Laravel * Bootstrap * Wordpress Themes/ Plugins. * Scrapping * UI/UX * Android and More

$15 USD in 1 day
(56 Reviews)

Hello, How are you? I read your job with interest. I can do it. I’m an expert Web Developer with more than 5 years experiences on WODRPRESS(“Theme” and “Plugin”), CODEIGNITER, PHP, OOP, MYSQL, MYSQLI, JAVACSRICT More

$15 USD in 0 days
(36 Reviews)

Hi, Lets discuss. I have 8 years of experience in PHP and following framework and cms i also worked on following technologies 1)Joomla 2)Wordpress 3) Smarty template engine 4) Magento 5) Drupal 6) Kohana More

$15 USD in 1 day
(18 Reviews)

Please give me one chance. I am very experienced butnew in freelancing. Thanks

$15 USD in 0 days
(15 Reviews)

i got the issue lets discuss in chat looking forward for your reply start it immediately create milestone and award me i will give you solution

$15 USD in 1 day
(13 Reviews)

Dear Employer; I am professional SEO friendly website designer and developer. I have 5+ years of experience with more than 100 successful projects. I would give you multiple amendments and charge less for my high Qua More

$15 USD in 0 days
(25 Reviews)

Hello, We have clearly understood your requirements and we too are willing to make some long-term clients, also we are available according to your time zone. we can do it in in hr. We have all the skills and experie More

$30 USD in 1 day
(9 Reviews)

I have dedicated the last four years to website deign and development, I have extensive knowledge with a variety of applications and web languages including Adobe applications as well as in-depth expertise in CSS3, HTM More

$20 USD in 10 days
(2 Reviews)

hello i am expert in my work i will show my work ping me and we will discuss thanks

$20 USD in 1 day
(2 Reviews)
$15 USD in 10 days
(2 Reviews)

I would like with this letter of motivation to acknowledge you about the fact that I wanna involve in fulfilling your project. Sincerely, Ioan-Tudor Stratulat

$15 USD in 0 days
(0 Reviews)

I have vast experience of jQuey, PHP and HTML I can fix this issue in an hour. I have fixed many issues of this type

$20 USD in 1 day
(0 Reviews)

Will do it for free just for the review_____________________________________________________________

$15 USD in 10 days
(0 Reviews)