• 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

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
 
Ever since I found this suit I've felt strange new needs. And a tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic