Java Tutorial/JSTL/Form CheckBox — различия между версиями

Материал из Java эксперт
Перейти к: навигация, поиск
м (1 версия)
 
м (1 версия)
 
(нет различий)

Текущая версия на 15:24, 31 мая 2010

Use Bean to Deal with CheckBox

index.jsp



<HTML>
<!--
 Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at
      http://www.apache.org/licenses/LICENSE-2.0
  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<BODY bgcolor="white">

<FORM TYPE=POST ACTION=checkresult.jsp>
<BR>
<font size=5 color="red">
Check all Favorite fruits: <br>
<input TYPE=checkbox name=fruit VALUE=apples> Apples <BR>
<input TYPE=checkbox name=fruit VALUE=grapes> Grapes <BR>
<input TYPE=checkbox name=fruit VALUE=oranges> Oranges <BR>
<input TYPE=checkbox name=fruit VALUE=melons> Melons <BR>

<br> <INPUT TYPE=submit name=submit Value="Submit">
</font>
</FORM>
</BODY>
</HTML>





Use Choose/When/Otherwise to Check Form CheckBox Data

index.jsp



<form method="post" action="checkbox.jsp">
  <P>Please check adjectives you would
  use to describe this web site"s
  customer service:</p>
  <P>Atrocious
  <input type="checkbox" name="feedback" value="atrocious"/></p>
  <P>Loathsome
  <input type="checkbox" name="feedback" value="loathsome"/></p>
  <P>Flagitious
  <input type="checkbox" name="feedback" value="flagitious"/></p>
  <P>Satisfactory
  <input type="checkbox" name="feedback" value="satisfactory"/></p>
  <P><input type="submit" value="Submit" /></p>
</form>





Use ForEach to Check Form CheckBox Data

index.jsp



<form method="post" action="checkbox.jsp">
  <P>Please check adjectives you would
  use to describe this web site"s
  customer service:</p>
  <P>Atrocious
  <input type="checkbox" name="feedback" value="atrocious"/></p>
  <P>Loathsome
  <input type="checkbox" name="feedback" value="loathsome"/></p>
  <P>Flagitious
  <input type="checkbox" name="feedback" value="flagitious"/></p>
  <P>Satisfactory
  <input type="checkbox" name="feedback" value="satisfactory"/></p>
  <P><input type="submit" value="Submit" /></p>
</form>