Getting parameters from radiobuttons and checkboxes
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Zeta_Kouper
Posted On:   Wednesday, February 23, 2005 03:25 PM

Hi.

I am trying to parseInt a variable from a Radiobutton :

int h = Integer.parseInt(request.getParameter("mem"));

in a JSP page,but it doesn't work!
What should I do ?

Furthermore if I call gerParameterValues when I have checkboxes, it has the same problem and as I can see the values aren't saved correctly in a String array as the are supposed to.

Thanx!
Zeta

Re: Getting parameters from radiobuttons and checkboxes

Posted By:   Mehdi_Naderi  
Posted On:   Wednesday, February 23, 2005 05:25 PM

make your radio buttons like this:












where n and v is what you want to be as the name and values of the radio buttons, the write your jsp code like this:



String value = request.getParameter("v");
try {
int v = Integer.parseInt(value);
// do your work with v.
}
catch(NumberFormatException e) {
// the value v can not parse as an integer.
// so change v in the definitions of radio buttons to be an integer.
}
About | Sitemap | Contact