[thelist] for loop, array and mouseover teazer

Chris Price chris.price at choctaw.co.uk
Thu Sep 13 03:51:58 CDT 2007


Lee Kowalkowski wrote:
> On 12/09/2007, Chris Price <chris.price at choctaw.co.uk> wrote:
>   
>> Lee Kowalkowski wrote:
>>     
> - you've got more of a scope issue than I first thought.
>
> Solving the scope of 'i' broke the closure over MyWorld and MyDesc that you had.
>
> I'm sure you can fetch the MyWorld element from its ID, but MyDesc is different.
>
> In these stuations I am more inclined to do the following:
>
>   function mouseover()
>   {
>     var myWorld = document.getElementById('<myWorldId>');
>     myWorld.nodeValue = this.desc + ' world';
>   }
>
>   for (i in MyDesc)
>   {
>     var MyPointer = document.getElementById(i)
>     MyPointer.desc = MyDesc[i];
>     MyPointer.onmouseover = mouseover;
>   }
>   
Thanks Lee, you're a star. There was no way I was going to figure that 
out otherwise.

I need to learn more about scope.

Kind Regards
-- 
Chris Price

Choctaw

chris.price at choctaw.co.uk
http://www.choctaw.co.uk

Tel. 01524 825 245
Mob. 0777 451 4488

Beauty is in the Eye of the Beholder
while Excellence is in the Hand of the Professional

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-+- Sent on behalf of Choctaw Media Ltd -+-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Choctaw Media Limited is a company
registered in England and Wales
with company number 04627649

Registered Office:
Lonsdale Partners,
Priory Close,
St Mary's Gate,
Lancaster LA1 1XB
United Kingdom





More information about the thelist mailing list