Read Form Multiple Selection Control : Form Select « JSP « Java Tutorial






<HTML>
    <HEAD>
        <TITLE>Submitting Multiple Selection Select Controls</TITLE>
    </HEAD>
 
    <BODY>
        <H1>Submitting Multiple Selection Select Controls<H1>
        <FORM ACTION="basic.jsp" METHOD="POST">
            <SELECT NAME="select1" SIZE="5" MULTIPLE>
                <OPTION>Option 1</OPTION>
                <OPTION SELECTED>Option 2</OPTION>
                <OPTION>Option 3</OPTION>
                <OPTION>Option 4</OPTION>
                <OPTION>Option 5</OPTION>
           </SELECT>
           <BR>
           <INPUT TYPE="SUBMIT" VALUE="Submit">
       </FORM>
    </BODY>
</HTML>
<HTML>
    <HEAD>
        <TITLE>Reading Multiple Selection Select Controls</TITLE>
    </HEAD>

    <BODY>
        <H1>Reading Multiple Selection Select Controls</H1>
        You selected:
        <BR>
        <% String[] items = request.getParameterValues("select1");
        for(int loopIndex = 0; loopIndex < items.length; loopIndex++){
            out.println(items[loopIndex] + "<BR>");
        }
        %>
    </BODY>
</HTML>
  Download:  ReadFormSelectionControlMultipleSelection.zip( 1 k)








23.23.Form Select
23.23.1.Read Form Multiple Selection Control
23.23.2.Read Form Selection Control
23.23.3.Deal with Form TextField and Select Option