In struts, How to dynamically add value to dropdown list if i click radio button

890 Views Asked by At

I am a beginner in struts, here my Question is dynamically add value into dropdown list when i check radio button. Already two values were present in dropdown list. if i click radio button two more values should add. i am using struts-html tag inside JSP page. Please give idea or suggest how to do this ?

Thanks in advance.

1

There are 1 best solutions below

1
Preuk On

One quick ad dirty way to do this would be messing with DOM events and javascript to change options in your select. This would add a third option to your select :

document.<formId>.<selectId>.options[2]=new Option("Label", "value", false, false)

For this to work, you'll have to retreive DOM ids for your tags (assuming worst case, i.e. struts 1)