Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

simple radio button question

  • 12-11-2005 6:27am
    #1
    Registered Users, Registered Users 2 Posts: 868 ✭✭✭


    Hi,

    Java code problem - my servlet needs to check if a group radio button (submitted on a HTML form) has been selected or not.

    In other words - if the submit is clicked and none of the radio button options has been selected, what is the Java code to check?

    Make any sense?

    D.


Comments

  • Closed Accounts Posts: 4,943 ✭✭✭Mutant_Fruit


    if(!Button1.IsSelected && !Button2.IsSelected && !Button3.IsSelected)
    {
    Do Code for when nothing is selected
    }

    of course, syntax might be different for java, but the idea would be the same.


  • Closed Accounts Posts: 324 ✭✭madramor


    if(!Button1.IsSelected && !Button2.IsSelected && !Button3.IsSelected)
    {
    Do Code for when nothing is selected
    }

    of course, syntax might be different for java, but the idea would be the same.
    servlets are serverside components they only interact with
    the client using the HTTP protocol so the above will not work
    <FORM action="doit">
       <INPUT TYPE="RADIO" NAME="anything" VALUE="1">One</INPUT>
       <INPUT TYPE="RADIO" NAME="anything" VALUE="2">Two</INPUT>
       <INPUT TYPE="RADIO" NAME="anything" VALUE="3">Three</INPUT>
       <INPUT type="submit" value="doit">
    </FORM>
    
    String val = request.getParameter("anything");
    if(val == null)
       out.println("no buttons ticked");
    else
       out.println("Checked was: "+val);
       // will give 1 || 2 || 3
    


Advertisement