- Joined
- Jun 8, 2007
- Messages
- 1,961
- Reaction score
- 475
Oh what a tangled web I've weaved..
Just as I thought I completed my rating system, IE Browser seems to have trouble displaying one of my PHP generated directory pages.
I did a quick JavaScript tut on How to change multiple images on a single Roll-Over. Basically, I just wanted all the stars behind the rolled over star to light up for a simple visual for ratings. Like how Yahoo ratings work; When you roll over a star, all the ones before it should light up, and the ones after should dull out (turn grey in my case).
I need a JavaScript Wiz Kid to help me out here. I couldn't get the for(i=0;i<5;i++
loop working right, so I just followed the tutorial the site gave me and made it compatible to do 5 stars.
It works like this in the head:
I don't need a for(i) loop, I think it works fine like this and I'm not complaining.
This is where the stars are made in PHP:
When all is said and done, this is what gets exported to the browser's source to make 5 stars for 1 listing.(Enter Spaces added after each HTML enclosed brackets for readablillity. If ther were spaces in the source, there would be a space after each star.. too much space)
Notice: It only puts the onMouseOut option if the star is not lit up. In this listing, it has a rating of 4, so only the 5th star is programmed to turn off onMouseOut.
The varriable $parent is what I use to tell my server what part of the site it's on. For example, for Business Listing with the ID of 123, it exports: listing_123. If it were a rating on someone's profile with the ID of 15, (not invented yet, but hope for the future), it would export: profile_15. I break it apart later by splitting at the underscore.
This system seems to be working good on every generated page on every browser. Of corse, with the exception of IE, but only on the automotive page. Every other page I tried with IE worked fine, just like Firefox and Safari. Another thing, the Automotive page reacts fine with Safari and Firefox.
My question to you is: What could be causing a single browser (IE) to have a problem with 1/20 pages generated from the same exact source?
JavaScript Error: Object Expected
Problem Page (only broken on IE 7 for me..):
http://www.avsbest.com/categories/automotive.html
Just as I thought I completed my rating system, IE Browser seems to have trouble displaying one of my PHP generated directory pages.
I did a quick JavaScript tut on How to change multiple images on a single Roll-Over. Basically, I just wanted all the stars behind the rolled over star to light up for a simple visual for ratings. Like how Yahoo ratings work; When you roll over a star, all the ones before it should light up, and the ones after should dull out (turn grey in my case).
I need a JavaScript Wiz Kid to help me out here. I couldn't get the for(i=0;i<5;i++

It works like this in the head:
Code:
<SCRIPT language="JavaScript">
<!--
if (document.images)
{
pic1on= new Image(20,20);
pic1on.src="[URL]http://www.avsbest.com/images/rating_star1.png[/URL]";
pic2on= new Image(20,20);
pic2on.src="[URL]http://www.avsbest.com/images/rating_star1.png[/URL]";
pic3on= new Image(20,20);
pic3on.src="[URL]http://www.avsbest.com/images/rating_star1.png[/URL]";
pic4on= new Image(20,20);
pic4on.src="[URL]http://www.avsbest.com/images/rating_star1.png[/URL]";
pic5on= new Image(20,20);
pic5on.src="[URL]http://www.avsbest.com/images/rating_star1.png[/URL]";
pic1off= new Image(20,20);
pic1off.src="[URL]http://www.avsbest.com/images/rating_star0.png[/URL]";
pic2off= new Image(20,20);
pic2off.src="[URL]http://www.avsbest.com/images/rating_star0.png[/URL]";
pic3off= new Image(20,20);
pic3off.src="[URL]http://www.avsbest.com/images/rating_star0.png[/URL]";
pic4off= new Image(20,20);
pic4off.src="[URL]http://www.avsbest.com/images/rating_star0.png[/URL]";
pic5off= new Image(20,20);
pic5off.src="[URL]http://www.avsbest.com/images/rating_star0.png[/URL]";
}
function lightup(imgName,imgName2,imgName3,imgName4,imgName5)
{
if (document.images)
{
imgOn=eval("pic1on.src");
document[imgName].src= imgOn;
if(imgName2){
imgOn2=eval("pic2on.src");
document[imgName2].src= imgOn2;
} if(imgName3){
imgOn3=eval("pic3on.src");
document[imgName3].src= imgOn3;
} if(imgName4){
imgOn4=eval("pic4on.src");
document[imgName4].src= imgOn4;
} if(imgName5){
imgOn5=eval("pic5on.src");
document[imgName5].src= imgOn5;
}
}
}
function turnoff(imgName,imgName2,imgName3,imgName4,imgName5)
{
if (document.images)
{
imgOff=eval("pic1off.src");
document[imgName].src= imgOff;
if(imgName2){
imgOff2=eval("pic2off.src");
document[imgName2].src= imgOff2;
} if(imgName3){
imgOff3=eval("pic3off.src");
document[imgName3].src= imgOff3;
} if(imgName4){
imgOff4=eval("pic4off.src");
document[imgName4].src= imgOff4;
} if(imgName5){
imgOff5=eval("pic5off.src");
document[imgName5].src= imgOff5;
}
}
}
//-->
</SCRIPT>
I don't need a for(i) loop, I think it works fine like this and I'm not complaining.
This is where the stars are made in PHP:
PHP:
if($thisRating > 0) {
for($r=1;$r<=$thisRating;$r++) {
if(strlen($iRated)>1) {
$submitRatingURL = 'http://www.avsbest.com/categories/'.$category.'/editRating/'.$r.'_'.$_SESSION['SessionID'].'_'.$myRating.'/'.$parent.'.html#'.$parent;
} else if(strlen($_SESSION['SessionID'])>0) {
$submitRatingURL = 'http://www.avsbest.com/categories/'.$category.'/addRating/'.$r.'/'.$parent.'.html#'.$parent;
} else {
$submitRatingURL = 'http://www.avsbest.com/categories/'.$category.'.html#'.$parent;;
}
echo '<a href="'.$submitRatingURL.'" onMouseOver="lightup(';
for($t=1;$t<($r+1);$t++) {
echo "'".$parent."_".$t."'";
if($t<$r) {
echo ', ';
}
}
echo ')" />';
echo '<IMG width="20" height="20" src="http://www.avsbest.com/images/rating_star1" border="0" alt="Rating: '.$thisRating.'" name="'.$parent.'_'.$r.'" />';
echo '</a>';
}
for($r=1;$r<=(5-$thisRating);$r++) {
$s = $r+$thisRating;
if(strlen($iRated)>1) {
$submitRatingURL = 'http://www.avsbest.com/categories/'.$category.'/editRating/'.$s.'_'.$_SESSION['SessionID'].'_'.$myRating.'/'.$parent.'.html#'.$parent;
} else if(strlen($_SESSION['SessionID'])>0) {
$submitRatingURL = 'http://www.avsbest.com/categories/'.$category.'/addRating/'.$s.'/'.$parent.'.html#'.$parent;
}
echo '<a href="'.$submitRatingURL.'" onMouseOver="lightup(';
for($t=1;$t<=$s;$t++) {
echo "'".$parent."_".$t."'";
if($t<$s) {
echo ', ';
}
}
echo ')" onMouseOut="turnoff(';
for($t=$thisRating+1;$t<=$s;$t++) {
echo "'".$parent."_".$t."'";
if($t<$s) {
echo ', ';
}
}
echo ')" />';
echo '<IMG width="20" height="20" src="http://www.avsbest.com/images/rating_star0" border="0" alt="Rating: '.$thisRating.'" name="'.$parent.'_'.$s.'" />';
echo '</a>';
}
} else {
for($r=1;$r<6;$r++) {
if(strlen($_SESSION['SessionID'])>0) {
$submitRatingURL = 'http://www.avsbest.com/categories/'.$category.'/addRating/'.$r.'/'.$parent.'.html#'.$parent;
}
echo '<a href="'.$submitRatingURL.'" onMouseOver="lightup(';
for($t=1;$t<($r+1);$t++) {
echo "'".$parent."_".$t."'";
if($t<$r) {
echo ', ';
}
}
echo ')" onMouseOut="turnoff(';
for($t=1;$t<($r+1);$t++) {
echo "'".$parent."_".$t."'";
if($t<$r) {
echo ', ';
}
}
echo ')" />';
echo '<IMG width="20" height="20" src="http://www.avsbest.com/images/rating_star0" border="0" alt="Rating: '.$thisRating.'" name="'.$parent.'_'.$r.'" />';
echo '</a>';
}
}
When all is said and done, this is what gets exported to the browser's source to make 5 stars for 1 listing.(Enter Spaces added after each HTML enclosed brackets for readablillity. If ther were spaces in the source, there would be a space after each star.. too much space)
Code:
<a href="[URL]http://www.avsbest.com/categories/automotive.html#listing_247[/URL]" onMouseOver="lightup('listing_247_1')" >
<IMG width="20" height="20" src="[URL]http://www.avsbest.com/images/rating_star1[/URL]" border="0" alt="Rating: 4" name="listing_247_1" />
</a>
<a href="[URL]http://www.avsbest.com/categories/automotive.html#listing_247[/URL]" onMouseOver="lightup('listing_247_1', 'listing_247_2')" >
<IMG width="20" height="20" src="[URL]http://www.avsbest.com/images/rating_star1[/URL]" border="0" alt="Rating: 4" name="listing_247_2" />
</a>
<a href="[URL]http://www.avsbest.com/categories/automotive.html#listing_247[/URL]" onMouseOver="lightup('listing_247_1', 'listing_247_2', 'listing_247_3')" >
<IMG width="20" height="20" src="[URL]http://www.avsbest.com/images/rating_star1[/URL]" border="0" alt="Rating: 4" name="listing_247_3" />
</a>
<a href="[URL]http://www.avsbest.com/categories/automotive.html#listing_247[/URL]" onMouseOver="lightup('listing_247_1', 'listing_247_2', 'listing_247_3', 'listing_247_4')" >
<IMG width="20" height="20" src="[URL]http://www.avsbest.com/images/rating_star1[/URL]" border="0" alt="Rating: 4" name="listing_247_4" />
</a>
<a href="[URL]http://www.avsbest.com/categories/automotive.html#listing_247[/URL]" onMouseOver="lightup('listing_247_1', 'listing_247_2', 'listing_247_3', 'listing_247_4', 'listing_247_5')" onMouseOut="turnoff('listing_247_5')" >
<IMG width="20" height="20" src="[URL]http://www.avsbest.com/images/rating_star0[/URL]" border="0" alt="Rating: 4" name="listing_247_5" />
</a>
Notice: It only puts the onMouseOut option if the star is not lit up. In this listing, it has a rating of 4, so only the 5th star is programmed to turn off onMouseOut.
The varriable $parent is what I use to tell my server what part of the site it's on. For example, for Business Listing with the ID of 123, it exports: listing_123. If it were a rating on someone's profile with the ID of 15, (not invented yet, but hope for the future), it would export: profile_15. I break it apart later by splitting at the underscore.
This system seems to be working good on every generated page on every browser. Of corse, with the exception of IE, but only on the automotive page. Every other page I tried with IE worked fine, just like Firefox and Safari. Another thing, the Automotive page reacts fine with Safari and Firefox.
My question to you is: What could be causing a single browser (IE) to have a problem with 1/20 pages generated from the same exact source?
JavaScript Error: Object Expected
Problem Page (only broken on IE 7 for me..):
http://www.avsbest.com/categories/automotive.html