Manish Joshi wrote:
>
> hi i m attachin following code for checkboxes hope u can do same with radio
> buttons
Manish,
I don't mind at all that you distribute my examples from the JavaServer Page
book (O'Reilly), but I would really appreciate if you'd tell people where
it comes from. This example, and many others, can be found in the book
as well as on the web site for the book: <http://TheJSPBook.com/>
And yes, the same approach works for radio buttons.
Hans
> <%@ page language="java" contentType="text/html" %>
> <%@ page import="com.ora.jsp.util.*" %>
> <html>
> <body bgcolor="white">
>
> <form action="checkbox.jsp">
> <input type="checkbox" name="fruits" value="Apple">Apple<br>
> <input type="checkbox" name="fruits" value="Banana">Banana<br>
> <input type="checkbox" name="fruits" value="Orange">Orange<br>
> <input type="submit" value="Enter">
> </form>
>
> <%
> String[] picked = request.getParameterValues("fruits");
> if (picked != null && picked.length != 0) {
> %>
> You picked the following fruits:
> <form>
> <input type="checkbox" name="fruits" value="Apple"
> <%= ArraySupport.contains(picked, "Apple") ?
> "checked" : "" %> >Apple<br>
> <input type="checkbox" name="fruits" value="Banana"
> <%= ArraySupport.contains(picked, "Banana") ?
> "checked" : "" %> >Banana<br>
> <input type="checkbox" name="fruits" value="Orange"
> <%= ArraySupport.contains(picked, "Orange") ?
> "checked" : "" %> >Orange<br>
> </form>
> <% } %>
> </body>
> </html>
>
> regards
> manish joshi
--
Hans Bergsten [EMAIL PROTECTED]
Gefion Software http://www.gefionsoftware.com
Author of JavaServer Pages (O'Reilly), http://TheJSPBook.com
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets