Domanda

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>
È stato utile?

Soluzione 2

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

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

Altri suggerimenti

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top