W3C home > Mailing lists > Public > www-forms@w3.org > October 2003

Re: Defining "onClick"-Events in XForms Controls

From: Steven Pemberton <steven.pemberton@cwi.nl>
Date: Thu, 9 Oct 2003 23:09:00 +0200
Message-ID: <053701c38ea9$92bcf4a0$df13fea9@srx41p>
To: "Roman Huditsch" <roman.huditsch@hico.com>, <www-forms@w3.org>

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



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

Very much better.

    <html:script ev:event="DOMActivate"

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

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

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 ev:observer="tr" ev:event="DOMActivate" type="text/javascript">

Then the trigger would look like this:

    <trigger id="tr">

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

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:36:09 UTC