2

I have a form that looks like this:

<form method="post" action="action.php">
   <select id='select' multiple='multiple'>
     <option value="1"> Option1 <option>
     <option value="2"> Option2 <option>
   </select>
</form>

My problem here is that this code only sends one(the last) option if both Options are selected to the action.php. Is there a way to make it send both options if both are selected? What am i missing?

1 Answer 1

4

Your select doesn't have a name attribute, so it wouldn't send anything at all. I'm going to assume that's a copy-paste error.

To return an array, you just need to set the name as an array, e.g.

<select id='select' multiple='multiple' name='yourname[]'>

(note the [])

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.