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>
1

1 Answer 1

0

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

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

Live example over here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.