Re: Defining "onClick"-Events in XForms Controls

From: "Roman Huditsch" <roman.huditsch@hico.com>

> How would I define a "onClick"-Event in an XForms control that calls a
> Javascript function?
>
> Would it look like
> <xforms:trigger html:onClick="javascript:test();">...

No! (By the way, onClick is a bit of code, not a URL, so it should read

    onclick="test();"

)

> or is there a better way to maybe omitt the "html:onClick" attribute?

Very much better.

<trigger>
    <label>Test</label>
    <html:script ev:event="DOMActivate"
type="text/javascript">test();</script>
</trigger>

would do nicely, assuming your host document markup allowed this, or

    <trigger ev:event="DOMActivate" ev:handler="#test">
        <label>Test</label>
    </trigger>

where '#test' identifies a script element with id="test" that calls test();.

The XML Events method of doing what Mark Birbeck suggested

    <script for="tr" event="DOMActivate" language="JavaScript">
      alert('Add some code here');
    </script>

is:

    <script ev:observer="tr" ev:event="DOMActivate" type="text/javascript">
        test();
    </script>

Then the trigger would look like this:

    <trigger id="tr">
        <label>Test</label>
    </trigger>

This would indeed allow you to have more than one handler for the same
event, as would the most general solution:

    <ev:listener event="DOMActivate" observer="tr" handler="#test"/>

where the script element has id="test".

Steven Pemberton

Received on Thursday, 9 October 2003 17:09:14 UTC