View Full Version : JS wont pass variable

12-19-2010, 11:26 PM

I have a JS value but it won't put the value in the brackets when i try to get the element by ID instead it is looking for the id named the same as the variable name.

Here is what i got to explain better:

function fill_div(v)
document.getElementById(v).innerHTML="<img src='untitle.png' style='width:100%;height:100%;'/>";
var x = 0;
var y = 3;
var area = 1;
window.onload = fill_div(area+':'+x+':'+y);

It ends up looking for id v instead of id 1:0:3.

Any idea how i correct this ?

Logic Ali
12-20-2010, 03:54 AM
Event handlers must be passed a reference to a function:window.onload = function(){ fill_div(area+':'+x+':'+y); }

12-20-2010, 05:58 AM
I see now thanks :)