I have been bugged by a problem for a 2-3 days now. I couldnt find remedy from any posts i have seen here or other sources. I thought Maybe i could get some help in my own post. Here is the code:
$grn="/img/grn.png";
$red="/img/red.png";
echo "<script>";
$cnt=0;
for($i=0;$i<3;$i++)
{
$cnt=$cnt+100;
for($a=1;$a<30;$a++)
{
$iid=$cnt+$a;
echo "$(document).ready(function()
{
$(\"#".$iid."\").click(function()
{
$.get(\"test.php\",{ iddd : ".$iid."},function(data)
{
if(data==1)
{
$(\"#".$iid."\").css('background-image',url(\"img/grn.png\"));
$(\"#dene\").html(\"<p>GREEN ".$iid."</P>\");
}
if(data==0)
{
$(\"#".$iid."\").css('background-image',url(\"img/red.png\"));
$(\"#dene\").html(\"<p>RED ".$iid."</P>\");
}
})
})
});";
}
}
echo "</script>";
I am aware my indentations are not very well. But I am kinda in hurry. My problem is that, the line :
$(\"#".$iid."\").css('background-image',url(\"img/grn.png\"));
is not working. And when it doesnt execute, jquery also doenst execute the other statement in the same if statement. Any idea why it c ould happen ? Thanks in advance.