Hello. I have a web page and i want user to be able to select multiple options. The problem is that when i write

<select name="aha">
<option value="hhh">HHH</option>
<option value="kkk">KKK</option>
<option value="ppp">PPP</option>

There is no problem in my JSP page.

But later when i try to write

<select multiple name="aha">
<option value="hhh">HHH</option>
<option value="kkk">KKK</option>
<option value="ppp">PPP</option>

I can't seem to see the list properly. I have 28 values in my list.

What might be my problem?

Dani AI

Generated

A few focused points to resolve the visual problem and make a 28-item multi-select usable.

A common cause is simply that browsers default to one visible row unless a visible size is given; this is the practical fix that suggested. In addition, XHTML requires the full form multiple="multiple" while HTML5 accepts the boolean multiple. Check the DOCTYPE and the exact markup style the page is being served as (HTML vs XHTML) because that affects how attribute syntax is interpreted.

Possible layout/CSS causes to check next: a parent container with overflow:hidden or a fixed height/max-height can clip the control; some CSS resets or frameworks also set form controls to a specific height. Use the browser inspector to view the computed height and overflow on the select and its ancestors. If the visual list must remain compact, set a reasonable size (visible rows) or a CSS height so the control shows a scrollbar instead of being clipped.

Server-side note for JSP: multiple selections are returned as an array on submit. Example retrieval in a servlet/JSP:

String[] selected = request.getParameterValues("aha");
if (selected != null) {
    for (String s : selected) {
        out.println(s + "<br/>");
    }
}

Do not rely on PHP-style name[] syntax for Java; keep the same name and use request.getParameterValues.

UX tips for long lists: group items with <optgroup> for clarity, limit visible rows and allow scrolling, or use a JavaScript multi-select widget (dual-listbox or enhanced select) if users must frequently pick many items. Also remember platform selection keys differ (Ctrl/Shift on Windows, Command/Shift on macOS).

Recommended Answers

All 2 Replies

I took this example:

<select multiple="multiple">
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="mercedes">Mercedes</option>
  <option value="audi">Audi</option>
</select>

From this site:
http://www.w3schools.com/tags/att_select_multiple.asp

try adding the parameter size

<select multiple="multiple" size="10" name="a">
<option value="1">1</option>
...
</select>

Your final file is HTML or XHTML?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.