Hi all,

I have two radio button yes,no in a.jsp.
var IncludeCharges = document.getElementById("IncludeCharges_no").value;

If i select yes i need to pass 1 to the java file and in case of no i need to pass 0. but when i retrive the radio button value using

int Includecharges = Integer.parseInt(request.getParameter("IncludeCharges_yes");

It shows undefined...

How could i get the value

Thanks in advance...

Based on the fact that you are using document.getElementById("IncludeCharges_no").value , my guess is that you have:

<input type="radio" id="IncludeCharges_no".../>
<input type="radio" id="IncludeCharges_yes".../>

However, the browser does NOT provide/send the id to the server. Instead, it uses the name. So all you need to do is give both buttons the same name. Only the name and value of the checked item will be sent:

<input type="radio" id="IncludeCharges_no" name="IncludeCharges" value="0" />
<input type="radio" id="IncludeCharges_yes" name="IncludeCharges" value="1" />

On another note, this:

int Includecharges = Integer.parseInt(request.getParameter("IncludeCharges_yes");

is missing a closing parenthesis, but with the changes in html as suggested it should be:

int Includecharges = Integer.parseInt(request.getParameter("IncludeCharges"));