Call dropdown selected value in script

classic Classic list List threaded Threaded
3 messages Options
nhl
Reply | Threaded
Open this post in threaded view
|

Call dropdown selected value in script

nhl
How to get the Orbeon dorpdown selected value in script ?

It works fine with radio buttons with following sample code,

but need to know how to do same for select1 with attribute appearance="dropdown" ??

<xf:select1 id="User-Status-control" ref="instance('User-status')/item"
                                                            bind="User-Status-bind"
                                                            appearance="dropdown">

My success radio button action code as follows,

<xf:select1 id="User-Status-control" appearance="full" bind="User-Status-bind">
                <xf:label ref="$form-resources/User-Status/label"/>
                <xf:hint ref="$form-resources/User-Status/hint"/>
                <xf:alert ref="$fr-resources/detail/labels/alert"/>
               
                <xf:itemset ref="instance('User-status')/item">
                        <xf:label ref="@value"/>
                        <xf:value ref="@name"/>
                </xf:itemset>
               
                <xf:action ev:event="xforms-value-changed">
                <xf:setvalue ref="instance('selected-values')/selected-alive" value="''"/>

               

                <xxf:script> 
                        var op1 =  ORBEON.xforms.Document.getValue(this);
                        alert("op1 : " + op1);                                                                          

                        if(op1 == 0){
                                // TODO
                        }                                                                            
                        if(op1 == 1){
                                // TODO
                        }

                        ...

                </xxf:script>
        </xf:action> 
</xf:select1>

Reply | Threaded
Open this post in threaded view
|

Re: Call dropdown selected value in script

Alessandro  Vernet
Administrator
For those finding this thread through a search, this question has been cross-posted on Stack Overflow, and answered there:

http://stackoverflow.com/questions/36191897/how-to-pass-orbeon-dropdown-control-selected-value-to-script

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
nhl
Reply | Threaded
Open this post in threaded view
|

Re: Call dropdown selected value in script

nhl
This post was updated on .
Thanks Alex,

Issue is ORBEON.xforms.Document.getValue(control-id); worked for Radio Buttons, but it does not support for dropdown list. It returns 'op1: undefined' for following code,

var op1 =  ORBEON.xforms.Document.getValue(control-id);
alert("op1 : " + op1);

-NHL