HLP: DHTML/Javascript

J

John Smith

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!
 
M

Michael Winter

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...
 
J

John Smith

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 said:
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...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top