Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

handle radio buttons in servlet

 
harsha galla
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
harsha galla
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have got it. I have used javascript to change the other button unchecked to solve the issue. Any other ideas are welcome..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic