Re: setting xforms control value with javascript

I found a problem using the crypto.signText function of Javascript.

Given this code:

<head>
    ...
    <script language="javascript">
        <![CDATA[
        function sign() {
            var model = document.getElementById("request");
            var instance = model.getInstanceDocument("signedDoc");
            var textElements = instance.getElementsByTagName("signature");
            textElements[0].firstChild.nodeValue = crypto.signText(
document.getElementById('form').innerHTML, "auto");
            model.rebuild();
            model.refresh();
        }
        ]]>
    </script>

    <xforms:model id="request">
        ...
        <xforms:instance id="signedDoc">
            <data>
                <signature/>
            </data>
        </xforms:instance>
        <xforms:bind nodeset="instance('signedDoc')/signature"
id="signature"/>
        ...
    </xforms:model>
</head>

<body>
    <div id="form">
        ...

        ...
    </div>

    <xforms:trigger>
        <xforms:label>To sign the form</xforms:label>
        <xforms:load resource="javascript:sign()" ev:event="DOMActivate"/>
    </xforms:trigger>

    <xforms:textarea bind="signature">
        <xforms:label>Signed form (PKCS#7 format)</xforms:label>
    </xforms:textarea>
    </p>
</body>

It doesn't work. The element 'signature' of the instance must have some
value, although it is blank. Therefore:
<data>
      <signature> </signature>
</data>


Greetings
Iņaki

Received on Monday, 22 January 2007 20:13:37 UTC