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.

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]



<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"/>


Thank you in advance!

Recommended Answers

All 2 Replies

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

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

Thank you!

You solved my problem in seconds.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.