• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 255
  • Last Modified:

HTML Drop Down List with Multiple Selections

I am trying to create a drop down list that will allow to select more than one option.

Using the code below creates a list but that can only be scrolled down with the arrow keys and it not obvious if you don't know. Also I need the selected values to be return as follows

<select size="1" name="Test" multiple>
<option>1</option>
<option>2</option>
</select>

1
2

and not

1,2

Is there any easy way of accomplishing this without using complex code from ASP or Java?
0
broccolini
Asked:
broccolini
1 Solution
 
Chris StanyonCommented:
You can only have the dropdown if you don't set it to multiple. If you set it to multiple, then the dropdown disappear and you box will be a set number of rows deep. The reason you can only use the arrows is because you have the size set to 1.

Also, to return all the selected values you need to name your <select> as an array. You can then loop through the selected items in your handler script.

<select size="3" name="Test[]" multiple>
	<option>1</option>
	<option>2</option>
	<option>3</option>
	<option>4</option>
	<option>5</option>
	<option>6</option>
</select>

Open in new window

0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now