wood burning stoves 2.0*
The moose likes Servlets and the fly likes Reading Radio Button values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Reading Radio Button values" Watch "Reading Radio Button values" New topic
Author

Reading Radio Button values

Swati Kadam
Ranch Hand

Joined: Mar 05, 2008
Posts: 39
My HTML file is as follows...here i am displaying two questions and providing multiple choces for answers..
So i have use two radio button groups...Q1 and Q2..
Now..in my servlet i can use request.getParameter("Q1") to read the selected answer of the group Q1..
What if i want to read values of all radio button group values at same time...is there any method which returns valus of Q1,Q2 as an group?
Hop I have explined my doubt clearly...



<META NAME="Description" CONTENT="">
</HEAD>

<BODY>
<form name="Form1"
action="http://localhost:8080/examples/servlet/QuizServlet">
1) Which of the following lines will compile without warning or error.

<BR>
<INPUT type="radio" name="Q1" value="1"> float f=1.3;<BR>
<INPUT type="radio" name="Q1" value="2"> char c="a"; <BR>
<INPUT type="radio" name="Q1"value= "3"> byte b=257; <BR>
<INPUT type="radio" name="Q1" value="4"> boolean b=null; <BR>
<INPUT type="radio" name="Q1" value="5"> int i=10; <BR><BR>
2) A byte can be of what size
<BR>

<INPUT type="radio" name="Q2" value="1" > -128 to 127 <BR>
<INPUT type="radio" name="Q2" value="2"> (-2 power 8 )-1 to 2 power 8 <BR>
<INPUT type="radio" name="Q2" value="3"> -255 to 256 <BR>
<INPUT type="radio" name="Q2" value="4"> depends on the particular implementation of the Java Virtual machine <BR>
<input type=submit value="submit">

</BODY>
</HTML>


SCJP / Preparing For SCWCD
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60755
    
  65

getParameterMap() will return a map of request params.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

And getParameterValues will return a String[] containing all of the values for a given name.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ajith Prasad
Ranch Hand

Joined: Aug 22, 2006
Posts: 66
you can provide div id for each questions and get those values in div using for loop with div.length
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60755
    
  65

Originally posted by Ajith Prasad:
you can provide div id for each questions and get those values in div using for loop with div.length
No, you can't. id values are not passed to the server.
Ajith Prasad
Ranch Hand

Joined: Aug 22, 2006
Posts: 66
Who will pass the html id to the app server
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

The id doesn't get passed to the server.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reading Radio Button values
 
Similar Threads
Pass radio button to servlet
radio button values
help with radio buttons
setting a radio button
in which method shuld i use at the servlet code for request