0

I want to keep the selected values after I submit the form. My code works fine when I select only one value. It does not keep all values, when I select multiple values all at once. Please help.

<select name="education" id="education" multiple="multiple">
            <option value="Bachelor">Bachelor's
            <option value="Master">Master's
            <option value="PhD">PhD
</select>

        <script type="text/javascript">
            document.getElementById('education').value = "<?php echo $_POST['education'];?>";
        </script>
Panama Jack
  • 24,158
  • 10
  • 63
  • 95
Aaron F
  • 47
  • 1
  • 9
  • Possibly duplicate of http://stackoverflow.com/questions/2407284/how-to-get-multiple-selected-values-of-select-box-in-php – hindmost Feb 02 '14 at 19:28

1 Answers1

0

It does work with jQuery!:) You have to insert an array to the val():

     $('#education').val(['Bachelor', 'Master', 'PhD']);

Live example over here

Mr.TK
  • 1,743
  • 2
  • 17
  • 22