aspose file tools*
The moose likes JSP and the fly likes handle radio buttons in servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "handle radio buttons in servlet" Watch "handle radio buttons in servlet" New topic
Author

handle radio buttons in servlet

harsha galla
Greenhorn

Joined: Sep 24, 2008
Posts: 18
I have the following situation:
User fills a form which has 2 input text boxes and 2 radio buttons with a input text box each, depending on the radio button clicked the input text box of the other radio button is made read only (i.e you cannot fill that). Now when I submit the form a servlet handles the data but the problem is how would I know which radiobutton was clicked in the form and how to retrieve data from the input text box of that radio button leaving out the other one.
Moreover the servlet invokes different methods depending on the fields submitted.

thanks in advance.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30299
    
150

Harsha,
When you call request.getParameter("nameOfRadioButton") you get a value. One would be for each radio button. This lets you add logic to your servlet to see which field you should read.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
harsha galla
Greenhorn

Joined: Sep 24, 2008
Posts: 18
Thanks for your answer, but i do have another issue,
I have a more about 3 radio buttons, so to know which button was selected i need to give them all different names but that would create problems of displaying the buttons selected only one at a time, since to have a list of buttons selecting only one once we need to have them all named the same.May be if iam wrong in my thinking kindly correct it and also someone could suggest how to tackle this issue.

Thanks in advance
harsha galla
Greenhorn

Joined: Sep 24, 2008
Posts: 18
I have got it. I have used javascript to change the other button unchecked to solve the issue. Any other ideas are welcome..
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: handle radio buttons in servlet