PDA

View Full Version : Javascript function call in a php function problem



iuliser
14 Nov 2010, 05:29 AM
Hello. I tried to write a script that rotates two different pictures, each of them asociated with different url. I want to use this for more pairs of pictures. I made two javascript functions, one of them called in a php function. I'm new to javascript and I don't know where is the mistake I made, so I hope you can help me. The Javascript sequence is:


<script language="javascript" type="text/javascript">
seconds = "2";
function imgOne11(id,address1,address2,name1,picture1,picture2)
{
document.getElementById(id).innerHTML = '<a href="'+address1+'" target="_blank" ><img src="'+picture1+'" name="'+name1+'" border=0 /></a>';
setTimeout("imgTwo11(id,address1,address2,name1,picture1,picture2)", seconds * 1000);
}
function imgTwo11(id,address1,address2,name1,picture1,picture2)
{
document.getElementById(id).innerHTML = '<a href="'+address2+'" target="_blank"><img src="'+picture2+'" name="'+name1'" border=0 /></a>';
setTimeout("imgOne11(id,address1,address2,name1,picture1,picture2)", seconds * 1000);
}
</script>

and the php function is:


function imagine_partener2($address1,$address2,$tit,$picture1,$picture2,$idsp,$name1)
{return "<span id='$idsp'> <a href='$address1' target='_blank'> <img src='sponsori/$tit' name='$name1'

onLoad=\"imgOne11($idsp,$address1,$address2,$name1,$picture1,$picture2)\" style='width:170px;'/> </a></span>";
}

Thank you!

is_numeric
15 Nov 2010, 06:10 AM
your variable....

seconds = "2";

is out of scope.

try this...

var seconds = "2";