1

I have the following code and I want to be able to select multiple options when with a shift button. The following code displays a list of items in a drop down option menu: I have a table in the DB that have alist of books, so Iam populating the drop down menu with the table's data.

<select name="getfromall" id="getfromall" style="width:16em onChange=getBooks();">

<option value="All"><%=msg.getString("All Books")%></option>
<%
   java.util.ArrayList allBooks = Library.AddBook.getBookList("%");
       for(int i=0;i<allBooksl.size();i++)
              {
          %>
            <option value="<%=((String[])allBooks.get(i))[0]%>"
                      <%
        if( (getfromall1).equals(((String[])allBooks.get(i))[0]) )
                               out.print("selected");%>>

 <%=((String[])allBooks.get(i))[1]%>
</options>
<%
}//end if
%>
</select>
Uooo
  • 6,204
  • 8
  • 36
  • 63
spitti84
  • 121
  • 2
  • 4
  • 11

2 Answers2

1

Use multiple to allow multiple selection and size to say how many options to be presented to the user.

<select name="getfromall" multiple="multiple" size="5" ...>

http://www.w3.org/TR/html-markup/select.html

Robert Watts
  • 179
  • 2
  • 10
0

You need to use the multiple attribute on your <select> tag:

<select multiple name="getfromall" ... >
Uooo
  • 6,204
  • 8
  • 36
  • 63
  • I noticed that the dropdown menu disapeared, I wonder how can I keep the dropdown menu and be able to select two or more items for the list with mouse or shift? – spitti84 Feb 27 '13 at 22:37
  • Selecting multiple options from a dropdown menu is not possible. – Uooo Feb 28 '13 at 05:18