Link to home
Start Free TrialLog in
Avatar of SunScreenCert
SunScreenCert

asked on

ajax call with two radio buttons

Hi,

I have a field billable and i have two radio buttons yes and no. If app.getBillable value is 0, then i want the radio button yes be checked else i want no be checked. Please tell me how can i achieve this conditional checking in a servlet file.

Thanks,
SOLUTION
Avatar of rrz
rrz
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SunScreenCert
SunScreenCert

ASKER

No,
Please refer to the code below. This is a .java file. Since i have used ajax, i am using this file for the creation of table and columns.

out.println("<tr><td>Billing Model");
                             
            out.print("<tr><td><input type='radio' name='appStatusDescription'value='0'>Prepaid<br>");
            out.print("' </td>");
             out.print("<td><input type='radio' name='appStatusDescription'value='1' checked>Postpaid<br>");
             
                  out.print("' </td></tr>");

Now all this is in a servlet whose response is taken by xmlhttprequest and the div of the jsp is updated.  Now based on the app.getBillingModel i want that either of them should be checked. So i want all this done in this servlet file. Please tell me how do i go for it.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
oh great..i would just try this out

I did the same thing but it is not working


String yesChecked = "";
            String noChecked = "";
            String checkString = "checked = \"checked\"";
            int billingModel = app.getBillingModel();
            if(billingModel == 0)
                yesChecked = checkString;
            else
                noChecked = checkString;
            out.println("<tr><td>Billing Model");
            out.print("<tr><td><input type='radio' name='appStatusDescription' value='0' " + yesChecked + ">Prepaid<br>");
            out.print("</td>");
            out.print("<td><input type='radio' name='appStatusDescription' value='1' " + noChecked + ">Postpaid<br>");
            out.print("</td></tr>");

What is not working ?  
what is printed ?  What source code is sent to the browser ?  
I see that none of the fields are checked when i use this code.
I don't see these fields in the source code  because all of the whole table with the billing model row is  coming from servlets and i have a div which it is updating, so i see only the div there like this
<div id="appresults" name="appresults">
          </div>
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial