Lefthand assignment - Why doesn't this lefthand assignment work? (Posted by Rhamphoryncus)

They have: 2 posts

Joined: Sep 1999

I know I the lefthand assignment is screwed up, but I can't figure out how to fix it. Any suggestions?

function flipimage(unit, img)
{
document.layers['unit'+unit+'Div'].images['unit'+unit+'Img'].src = 'images/'+img+'.gif'
}

John Pollock's picture

He has: 628 posts

Joined: Mar 1999

At first glance my best guess is to try the eval funtion on the right side, perhaps:

document.layers['unit'+unit+'Div'].images['unit'+unit+'Img'].src = eval('images/'+img+'.gif');

Let us know if it works for you. Smiling

They have: 2 posts

Joined: Sep 1999

nope, now I'm getting

document.layers["unit" + unit + "Div"].images has no
properties.

actually, I think I changed it at somepoint and got rid of the invalid lefthand assignment error.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.