By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,460 Members | 1,151 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,460 IT Pros & Developers. It's quick & easy.

HLP: DHTML/Javascript

P: n/a
Hello all, I have a page that generates a form with dynamic rows of data.

The dynamic part is done by javascript and I have added onClick, also
tried onFocus, attribute in the dynamic field.

In mozilla's it works like a charm and the DOM in mozilla shows input
text field correctly with the onClick attribute

IE however does not do anything, nada, nothing, even when I just specify
a simple alert(); ????? Help (am I going stupid or is IE stupid ?)

This is what I use to set the attribute, where the onClickArray contains
the diffirent onclicks for the dynamic fields:

formField.setAttribute('onClick',onClickArray[j]);
Any help gratly appreciated!
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Wed, 25 Feb 2004 03:32:37 GMT, John Smith <js****@js.com> wrote:
The dynamic part is done by javascript and I have added onClick, also
tried onFocus, attribute in the dynamic field.

In mozilla's it works like a charm and the DOM in mozilla shows input
text field correctly with the onClick attribute

IE however does not do anything, nada, nothing, even when I just specify
a simple alert(); ????? Help (am I going stupid or is IE stupid ?)

This is what I use to set the attribute, where the onClickArray contains
the diffirent onclicks for the dynamic fields:

formField.setAttribute('onClick',onClickArray[j]);


Try using

formField.addEventListener('click',listener);

or

formField.onclick = listener;

instead. Note that the former is a DOM method, so you should use feature
detection before using it - especially as IE doesn't support it. If
detection fails, you could fall back on the latter.

Be aware that 'listener', in both cases, is a reference to a function that
expects a single argument: event[1]. If you have a handler that takes your
own arguments, you can use an intermediary.

<input ... onclick="someHandler(this.form)">

might become

formField.onclick = function(evt) {
someHandler(this.form);
}

The operator, this, still refers the same input element in both cases.

Does that help?

Mike
[1] IE is different - there are no expected arguments. It stores the event
data in a different object, window.event. This event object also contains
different properties than that of the standard event object. Typical
Microsoft...

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #2

P: n/a
Super thanks,

and yes M$ has to screw every thing up ! did you hear that they are
trying to patent the virual desktop that *nix had for the last 20 years,
they even use KDE and gnome screen shorts in their patent.

If I did not know better I would think that their new bussiness plan is
to be just hated.

Michael Winter wrote:
On Wed, 25 Feb 2004 03:32:37 GMT, John Smith <js****@js.com> wrote:
The dynamic part is done by javascript and I have added onClick, also
tried onFocus, attribute in the dynamic field.

In mozilla's it works like a charm and the DOM in mozilla shows input
text field correctly with the onClick attribute

IE however does not do anything, nada, nothing, even when I just
specify a simple alert(); ????? Help (am I going stupid or is IE
stupid ?)

This is what I use to set the attribute, where the onClickArray
contains the diffirent onclicks for the dynamic fields:

formField.setAttribute('onClick',onClickArray[j]);

Try using

formField.addEventListener('click',listener);

or

formField.onclick = listener;

instead. Note that the former is a DOM method, so you should use feature
detection before using it - especially as IE doesn't support it. If
detection fails, you could fall back on the latter.

Be aware that 'listener', in both cases, is a reference to a function
that expects a single argument: event[1]. If you have a handler that
takes your own arguments, you can use an intermediary.

<input ... onclick="someHandler(this.form)">

might become

formField.onclick = function(evt) {
someHandler(this.form);
}

The operator, this, still refers the same input element in both cases.

Does that help?

Mike
[1] IE is different - there are no expected arguments. It stores the
event data in a different object, window.event. This event object also
contains different properties than that of the standard event object.
Typical Microsoft...

Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.