• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

List Of Radio buttons with other option

 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have a list of radio buttons, and one of the option is other, if other radio button is clicked i have to take a text box value with the same name as radio button, Can anyone help me please..

Thanks
Srilakshmi
 
Ranch Hand
Posts: 354
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can't do this as it is an HTML limitation. if you have 2 form elements with the same name (the 'other' radio value and the 'other' text field), the values will be combined into an comma-delimited value. the struts way to do this is name the radio option property something along the line of 'radioOption' and the text box 'otherValue'. in your action class, you need to have a conditional statement to change set the 'radioOption' value to the 'otherValue' field value.

alternatively, you can use javascript. when the user select 'other' radio button and enter value in the text box (name it anything you want), onSubmit, simply set the 'other' value to the value of the textbox before calling form.submit().
 
Srilakshmi Vara
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks alan i will work on it
 
What are your superhero powers? Go ahead and try them on this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!