W3C home > Mailing lists > Public > www-forms@w3.org > January 2007

Re: setting xforms control value with javascript

From: Iņaki Salinas Bueno <inksalinas@gmail.com>
Date: Mon, 22 Jan 2007 21:13:32 +0100
Message-ID: <cd3c31800701221213j4294e18ey254402f5cc849cf7@mail.gmail.com>
To: www-forms <www-forms@w3.org>
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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Saturday, 10 March 2012 06:22:08 GMT