In Progress

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.

<?php

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

echo $selectedOption."<br>";

}

?>

<script>

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;

}

}

</script>

<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[]">

<?php

$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>";

}

?>

</select></td>

<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[]">

</select></td></tr></table>

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

</form>

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

About the Employer:
( 5 reviews ) East Peoria, United States

Project ID: #14070521

Awarded to:

ainosoft

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
(35 Reviews)
4.5

17 freelancers are bidding on average $17 for this job

PhungTran

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

$15 USD in 10 days
(506 Reviews)
6.9
$15 USD in 0 days
(89 Reviews)
6.4
rohitagarberg

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
(317 Reviews)
6.5
PhpWebD

- 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
(57 Reviews)
5.4
$15 USD in 0 days
(91 Reviews)
5.6
nizamulamy

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
(48 Reviews)
4.5
techsoftpk

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
(39 Reviews)
4.5
phpdevelopercms

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
(25 Reviews)
4.3
kishanpala

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
(18 Reviews)
4.3
gauravgargcs

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
(14 Reviews)
4.3
irfan811

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
(20 Reviews)
4.3
malkaar

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

$15 USD in 0 days
(15 Reviews)
3.7
DhruvrajDahiya09

hello i am expert in my work i will show my work ping me and we will discuss [url removed, login to view] [url removed, login to view] [url removed, login to view] [url removed, login to view] thanks

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

Will do it for free just for the review_____________________________________________________________

$15 USD in 10 days
(0 Reviews)
0.0
gforgenious

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)
0.0