Re: XForms timer

On 4/26/06, Erik Bruchez <ebruchez@orbeon.com> wrote:
> If you can't do it directly with XForms, how do you do it, with Javascript?

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ev="http://www.w3.org/2001/xml-events"
      xmlns:xforms="http://www.w3.org/2002/xforms">
  <head>
    <title>Timer</title>
    <script type="text/javascript">
      function timer() {
        var ev = document.createEvent("Events");
        ev.initEvent("increment", true, true);
	document.getElementById("setv").dispatchEvent(ev);
	window.setTimeout(timer, 1000);
      }

      window.setTimeout(timer, 1000);
    </script>
    <xforms:model>
      <xforms:instance xmlns="">
        <data xmlns="">
          <counter>1</counter>
        </data>
      </xforms:instance>
      <xforms:setvalue id="setv" ref="counter" value=". + 1"
		       ev:event="increment"/>
    </xforms:model>
  </head>
  <body>
    <xforms:output ref="counter">
      <xforms:label>Counter: </xforms:label>
    </xforms:output>
  </body>
</html>

--
... Allan

Received on Thursday, 27 April 2006 16:36:58 UTC