Hi,
I am using struts 2 and facing an issue. I render a radio button with the struts tag like this:
<s:radio name="currnetObject.status
" list="statusList" onclick="toggle()"/>
Here, the 'statuslist' is a List (String) of values to be rendered as radio buttons.
The 'currentObject' is the object which holds the form fields being inserted/modified.
'status' is an attribute of the currentObject which has the selected radio button's value.
The radio buttons are rendered properly. When I select one of the radio button and save the form, the selected value if getting persisted properly. No issues.
The problem starts when I try to do something on the client side when the user chooses one of the radio buttons. I wrote a javascript function called 'toggle'. I'm trying the get the value of the radio choosed.
To do that in side the javascript function, I try to access the radio button like this :
"document.my_form.currentO
bject.stat
us" Please note that the name of the radio button is "currentObject.status". But the javascript throws an error as " 'status' is null or not an object".
I understand that javascript breaks because of the priod (".") in the field name. But that's the way to render the radio button using struts 2. Now, how do I access this kind of field names in the javascript function?
Thanks,
Madhan
Start Free Trial