Bruce Stemplewski
Bruce Stemplewski

Reputation: 1343

Radio button group Select & Change / onChange

It looks like the Select & Change / onChange event is not being called for my radion button group. In the SSJS sample below, the onChange event of radio button group should set the value of the edit box and also do a full update. Neither seems to be occurring.

<xp:radioGroup id="radioGroup1">
    <xp:selectItem itemLabel="One"></xp:selectItem>
    <xp:selectItem itemLabel="Two"></xp:selectItem>
    <xp:selectItem itemLabel="Three"></xp:selectItem>
    <xp:eventHandler event="onchange" submit="true"
        refreshMode="complete">
        <xp:this.action><![CDATA[#{javascript:getComponent("inputText1").setValue(getComponent("radioGroup1").getValue());}]]></xp:this.action>
    </xp:eventHandler>
</xp:radioGroup>
On Select should set this:&#160;<xp:inputText id="inputText1"></xp:inputText>
<xp:br></xp:br>
Selected Value:&#160;<xp:text escape="true" id="computedField1" style="font-weight:bold"><xp:this.value><![CDATA[#{javascript:return getComponent("radioGroup1").getValue();}]]></xp:this.value></xp:text>
<xp:br></xp:br>
<xp:button value="Update" id="button1">
    <xp:eventHandler event="onclick" submit="true"
        refreshMode="complete">
    </xp:eventHandler></xp:button>
<xp:br></xp:br>

Upvotes: 0

Views: 4272

Answers (2)

Adibabu Kancharla
Adibabu Kancharla

Reputation: 366

OnChange event for a radio group doesn't work properly in IE. OnClick event works. So you need to write code based on the browser, as follows.

<xp:radioGroup id="radioGroup1">
<xp:selectItem itemLabel="One"></xp:selectItem>
<xp:selectItem itemLabel="Two"></xp:selectItem>
<xp:selectItem itemLabel="Three"></xp:selectItem>
<xp:eventHandler event="onchange" submit="true" refreshMode="partial" refreshId="panelRadioVal" rendered="#{javascript:!context.getUserAgent().isIE()}" />
<xp:eventHandler event="onclick" submit="true" refreshMode="partial" refreshId="panelRadioVal" rendered="#{javascript:context.getUserAgent().isIE()}" />
</xp:radioGroup>
<xp:panel id="panelRadioVal">
    <xp:inputText value="#{javascript:getComponent('radioGroup1').getSubmittedValue()}" />
</xp:panel>

Upvotes: 5

user618792
user618792

Reputation:

It looks like your first getComponent in your eventhandler should be "inputText1" not "inputText".

Also, why perform a full update and not a partial refresh? Just trying to understand the business case.

Upvotes: 0

Related Questions