How ro read the value of a selectOneRadio in a Javascript function ?
lucborsNov 5 2008 — edited Nov 5 2008I have a selectOneRadio, and when I change it's value I need that value to do something in a javascript function.
I need the actual value (ONE, TWO or ALL) in that function but it looks like I only get the index of the selected radioButton (0,1 or 2)
Here's my Page source:
<af:selectOneRadio id="typeRadio" label="Type"
clientComponent="true"
autoSubmit="true"
binding="#{bean.TypeRadio}"
value="#{bean.Type}"
valueChangeListener="#{bean.typeChanged}">
<af:selectItem label="First Choice" value="ONE"/>
<af:selectItem label="Second Choice" value="TWO"/>
<af:selectItem label="All" value="ALL"/>
<af:clientListener method="setType" type="valueChange" />
</af:selectOneRadio>
Here's my js function;
function setType(evt)
{
var typeComp = evt.getSource().findComponent('typeRadio');
if (typeComp !=null){
alert('type = '+ typeComp.getValue());
type = compType.getValue());
//do some more actions and calculations
}
}
The Bolded alert shows me 0, 1 or 2 and not ONE, TWO or ALL.
Am I missing something ?