Topic
  • 1 reply
  • Latest Post - ‏2011-04-26T06:13:31Z by SystemAdmin
SuryaprakashRaghuwanshi
1 Post

Pinned topic How pass the instance paramate into javascript function

‏2011-04-22T07:22:36Z |
I want to send the model paramaters into a javascript.
Is it the proper way of doing? or any other process ?

<head>
<script type="text/javascript">
<![CDATA[ <b> function ulrWindow(){
alert('I want to pass this
<xforms:output ref="Demo-form-data"/>'); close()</b>}]]> </script>
<title>Survey Form Register</title>
<p:input name="data" href="#instance"/>
<xforms:model>
<xforms:instance id="main">
<xi:include href="input:data"/>
</xforms:instance>
<xforms:instance id="script">
<script url="javascript:close()"/>
</xforms:instance>
</xforms:model>
</head>
<body>








<center>

Thank you , for submitting the Application
<xforms:group ref="friend" >
<xforms:output ref="Demo-form-data"/>
</xforms:group>
</center>
<center>
<xforms:trigger>
<xforms:label>Close</xforms:label>
<xforms:load resource="javascript:ulrWindow()" ev:event="DOMActivate" />
</xforms:trigger>
</center>


</body>
</html>
Updated on 2011-04-26T06:13:31Z at 2011-04-26T06:13:31Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    265 Posts

    Re: How pass the instance paramate into javascript function

    ‏2011-04-26T06:13:31Z  
    What you have there might work, depending on the XForms implementation you are using. However, it might be a dangerous thing to do, as it puts you at the mercy of cross site scripting attacks. (If someone manages to input the value of Demo-form-data somewhere else in the app, and show it through this page, if you don't escape it properly, they can inject anything the want in the web page.)

    So in general, I prefer to use an <xforms:output id="your-output" ref="what you want to access in JavaScript" style="display: none"/> and access the value of your-output in JavaScript with the DOM API.

    Alex
    --
    Orbeon Forms - Web 2.0 Forms, open source, for the Enterprise
    http://www.orbeon.com/