Err... point taken, but a little pedantic in terms of actual
functionality... :)

(I am act. using onmouseout in my code...)

Thanks though I'll make sure I use the right code...

But do you have any ideas about what I am trying to do?

All the best...

Michael.



> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of
> Alexander Litvinov
> Sent: Tuesday, 18 December 2001 3:24 PM
> To: Michael Kraus; DynApi
> Subject: Re: [Dynapi-Help] EventListeners being dynamically set
> up on Array items.
>
>
> may be you should replace divLittener.onmouseoff to
> divLittener.onmouseout ?
>
> On Tuesday 18 December 2001 10:10, Michael Kraus wrote:
> > G'day all...
> >
> > I have an array of divs. which are held by another object (lets
> call it X).
> >
> > In the X' constructor, the div array is gone through, and an
> EventListener
> > is added to each one, but I want to access the for loops index
> from inside
> > the div's EventListener.
> >
> > The problem is the code for the div's EventListener is evaluated /after/
> > the for loop has executed and hence is always making an invalid to
> > reference.
> >
> > Eg.
> > // Inside constructor
> > for (i = 0; i < divArray.length; i++)
> > {
> >     divListener = new EventListener(divArray[i]);
> >     divLittener.onmouseover = function(e)
> >     {
> >             target = e.getTarget();
> >             target.setHTML("This is div#: " + i);
> >     }
> >     divLittener.onmouseoff = function(e)
> >     {
> >             target = e.getTarget();
> >             target.setHTML(" &nbsp; ");
> >     }
> > }
> >
> > So if there are 5 divs in the array, the HTML will always be
> "This is div#:
> > 5" for each of the div's.
> >
> > Is there a way to pass the for loops index as a parameter to the
> > EventListener at the for loops execution time, rather than the
> > EventListener's execution time?
> >
> > Currently I'm using a kludge which looks like:
> >
> > // Inside constructor
> > for (i = 0; i < divArray.length; i++)
> > {
> >     divArray[i].setHTML("<-- " + i + " -->");
> >     divListener = new EventListener(divArray[i]);
> >     divLittener.onmouseover = function(e)
> >     {
> >             target.setHTML(theHTML.substring(pos1, pos2+4) +
> "This is div#: " + x);
> >     }
> >     divLittener.onmouseoff = function(e)
> >     {
> >             target = e.getTarget();
> >             theHTML = target.getHTML();
> >             pos1 = theHTML.indexOf("<!-- ") + 5;
> >             pos2 = theHTML.indexOf(" -->");
> >             distance = pos2 - pos1;
> >             x = parseInt(theHTML.substr(pos1, distance));
> >
> >             target.setHTML(theHTML.substring(pos1, pos2+4) + "
> &nbsp; ");
> >     }
> > }
> >
> > Please tell me there is an easier way... :)
> >
> > All the best...
> >
> > Michael.
> >
> >
> > _______________________________________________
> > Dynapi-Help mailing list
> > [EMAIL PROTECTED]
> > https://lists.sourceforge.net/lists/listinfo/dynapi-help
>
> _______________________________________________
> Dynapi-Help mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/dynapi-help


_______________________________________________
Dynapi-Help mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dynapi-help

Reply via email to