0

Hi!


I have a function that i like to move 2 image objects around. (it works with 1)

But im getting errors while im trying to pass multiple object id-s.
I believe example will tell you more.

<script>
function Init()
{
   document.getElementById('pilt_kivi').style.left = x + 'px';
   document.getElementById('pilt_kivi').style.top = y + 'px';
   
   document.getElementById('flip').style.left = x2 + 'px';
   document.getElementById('flip').style.top = y2 + 'px';
}


function move(obj,obj2) 
{   
    obj.style.top=  amount;
    obj2.style.top= amount;

...

[U]There is a problem:[/U]
[B]window.setTimeout("move(" +obj.id+,obj2.id+ ");",10); [/B]

}
</script>

<body>

<a href="javascript:Liiguta(pilt_kivi,flip)">move</a><br>


[U]There are 2 objects pilt_kivi and flip:[/U]
<img class="image" id="pilt_kivi" src="paper.gif"/>
<img class="image" id="flip" src="paper.gif"/>

</body>

Thank you in advance!

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by m1n1m3
0

The problem is that you didn't do it in a string way. :)

window.setTimeout("move(" +obj.id+","+obj2.id+ ");",10);
0

Thank you!

You solved my problem in seconds.

I guess i was too under experienced to see obvious :D.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.