Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reading Radio Button values

 
Swati Kadam
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64824
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
getParameterMap() will return a map of request params.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And getParameterValues will return a String[] containing all of the values for a given name.
 
Ajith Prasad
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64824
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Who will pass the html id to the app server
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The id doesn't get passed to the server.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic