Long story short, I need a php if else statement to recognize a change to an image due to javascript.
I'll post a condensed version of the code:
Code:
<html>
<head>
<script type="text/javascript">
function mouseOver1()
{
document.rating1.src ="blog/img/star.png";
}
function mouseOut1()
{
document.rating1.src ="blog/img/nostar.png";
}
function onClick1()
{
document.rating.src ="blog/img/1.png";
document.rating1.src ="blog/img/star.png";
}
</script>
</head>
<body bgcolor=ffffff>
<center>
<img border="0" src="blog/img/nostar.png" name="rating1" value="One" id="rating1" width="16" height="16" onmouseover="mouseOver1()" onmouseout="mouseOut1()" onclick="onClick1()" />
<br /><br />
<img border="0" src="blog/img/0.png" name="rating" value="Zero" id="rating">
</center>
</body>
</html> Obviously the current onClick function is pointless thanks to the mouseOut function, but that's not my concern. I want something similar to the following, but a working version:
Code:
<?
if (document.rating.src=="blog/img/1.png")
echo "1 Star";
elseif (document.rating.src=="blog/img/2.png")
echo "2 Stars";
elseif (document.rating.src=="blog/img/3.png")
echo "3 Stars";
elseif (document.rating.src=="blog/img/4.png")
echo "4 Stars";
elseif (document.rating.src=="blog/img/5.png")
echo "5 Stars";
?>
It's a rating from 1 to 5 stars, but since I just posted a condensed version, I only really need a condensed solution and I can apply it from there. Basically, when you click the 1st star, image 1.png replaces image 0.png, when you click the 2nd star, image 2.png replaces image 0.png and so on up to the 5th star image. The problem is the php doesn't recognize the change to the rating src to echo anything based on the change.
Would I need to amend the php coding or the javascript? If so, what?