Documentation / XForms / JavaScript Integration

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Documentation / XForms / JavaScript Integration

Alessandro  Vernet
Administrator
As there has been some discussion in the list about how to access the
value of an XForms control from JavaScript, we have just added a short
section on this subject to the documentation. The text is included
below. Just let me know if you have any comment or correction.

Alex

----------------------------------------------------
14. Javascript Integration

While XForms gets you a long way towards creating a dynamic
user-friendly user interface, there some dynamic behaviors that cannot
be implemented with XForms, and that you might want to implement
directly in JavaScript. We describe here how your JavaScript code can
interact with XForms and in particular how you can have access to the
value of an XForms control.

With the current version of PresentationServer, accessing the value of
a control is only supported for <xforms:input>. If you want to access
the value of another control, add an <xforms:input> with
style="display: none" bound to the same node as that control and
access the <xforms:input>.

In JavaScript, you obtain a reference to the element representing the
control with var control = document.getElementById('myControl') where
myControl is the id of the XForms control (i.e. <xforms:input
id="myControl">. You can read the current value of the control with
control.value and set the value of the control assigning a value to
control.value, for instance: control.value = 42. When you do such an
assignment the value of the node in the instance is updated, the
xforms-value-changed event thrown, and all the standard XForms
processing happens (validation, recalculation, etc).



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet