Jsp Form Action: Design Your Sandwich : Form CheckBox « JSP « Java






Jsp Form Action: Design Your Sandwich

<HTML>
    <HEAD>
        <TITLE>Design Your Sandwich!</TITLE>
    </HEAD>
 
    <BODY>
    <% 
        String cheese = "", turkey = "", ham = "";
        String check1 = "", check2 = "", check3 = "";
        if(request.getParameter("radios") != null) {
           if(request.getParameter("radios").equals("cheese")){
               cheese = "CHECKED";
               check2 = "CHECKED";
           }
           if(request.getParameter("radios").equals("turkey")){
               turkey = "CHECKED";
               check1 = "CHECKED";
               check3 = "CHECKED";
           }
           if(request.getParameter("radios").equals("ham")){
               ham = "CHECKED";
               check1 = "CHECKED";
               check2 = "CHECKED";
               check3 = "CHECKED";
           }
       }
    %>

        <H1>Design Your Sandwich!</H1>
        <FORM METHOD="POST">
            <TABLE BORDER="1" ALIGN="LEFT">
                <TR>
                    <TH>
                        Sandwich
                    </TH>
                </TR>
                <TR>
                    <TD>
                        <INPUT TYPE="radio" NAME="radios" VALUE="cheese"
                            <%= cheese %>
                        >
                       Cheese Sandwich
                       <BR>
                       <INPUT TYPE="RADIO" NAME="radios" VALUE="turkey"
                           <%= turkey %>
                       >
                       Turkey Sandwich
                       <BR>
                       <BR>
                       <INPUT TYPE="RADIO" NAME="radios" VALUE="ham"
                            <%= ham %>
                       >
                       Ham Sandwich
                       <BR>
                   </TD>
               </TR>
            </TABLE>
    
            <TABLE BORDER="1" ALIGN="LEFT">
                <TR>
                    <TH>
                        Ingredients
                    </TH>
                </TR>
                <TR>
                    <TD>
                        <INPUT TYPE="CHECKBOX" NAME="check1" VALUE="check1"
                            <%= check1 %>
                        >
                        Meat
                        <BR>
                        <BR>
                        <INPUT TYPE="CHECKBOX" NAME="check2" VALUE="check2"
                            <%= check2 %>
                        >
                        Cheese
                        <BR>
                        <BR>
                        <INPUT TYPE="CHECKBOX" NAME="check3" VALUE="check3"
                            <%= check3%>
                        >
                        Lettuce
                    </TD>
                </TR>
            </TABLE>
            <BR CLEAR="ALL">
            <BR>
            <INPUT TYPE="SUBMIT" VALUE="Submit">
        </FORM>
    </BODY>
</HTML>

           
       








Related examples in the same category

1.Jsp Form CheckBox Demo
2.Submitting Check Boxes