On 12-05-22 01:18 PM, Mel Smith wrote:
> In my body 'onload' property/function, I call a function --
> part of which is shown below
[quote trimmed and cleaned up]
I'm assuming that you mean the `onload` attribute of the
body element. You may be interested in the following snippet[0]
from the HTML (5) specification:
"The onblur, onerror, onfocus, onload, and onscroll event
handlers of the Window object, exposed on the body element,
shadow the generic event handlers with the same names normally
supported by HTML elements."
In my experience, using the `onload` attribute of the body
element or the `onload` property of the Window object (for
Unobtrusive JavaScript zealots) is more stable than the
`onload` property of the body element (confirmed as absent
in Firefox 1-6 and Safari 3.1-4.)
> But, when I click on any option, the function myfunc() is not
> executed ??? (I put a simple alert in there and it does not
> show).
[quote trimmed and cleaned up]
Yes; you are correct in noting that the `click` event does
not work well with option elements. Perhaps, as has been
suggested in various threads before, you could add a `blur`
and/or `focus` event handler to the select element and track
"changes" that way. The first selected option (presence of
the `multiple` boolean attribute was not specified) can be
retrieved via the `selectedIndex`[1] property of the
`HTMLSelectElement`interface.
(e.g. `var curOption = sel.options[sel.selectedIndex];`)
[0]:
http://www.whatwg.org/specs/web-apps/current-work/multipage
/sections.html#the-body-element
[1]:
http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-85676760
--
Matt McDonald: Web/Flash Developer; Edmonton, Alberta, Canada