valonesal 0 Junior Poster

Ok so I have this script and I cant figure out how to add multiple star ratings to one page.

<? require "config.php" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta name="author" content="SMARTREVIEWSCRIPT.COM" />
<title>Add Your Review</title>
<link rel="stylesheet" href="style.css" type="text/css" />
<script type="text/javascript">
<!--
var set=false;
var v=0;
var a;
function loadStars()
{
   star1 = new Image(12,12);
   star1.src = "images/staroff.gif";
   star2 = new Image(12,12);
   star2.src= "images/staron.gif";
}

function highlight(x)
{
   if (set==false)
   {
   y=x*1+1
   switch(x)
   {
   case "1": 
   document.getElementById(x).src= star2.src;
   break;
   case "2":for (i=1;i<y;i++)
   {
   document.getElementById(i).src= star2.src;
   }
   break;
   case "3":for (i=1;i<y;i++)
   {
   document.getElementById(i).src= star2.src;
   }
   break;
   case "4":for (i=1;i<y;i++)
   {
   document.getElementById(i).src= star2.src;
   }
   break;
   case "5":for (i=1;i<y;i++)
   {
   document.getElementById(i).src= star2.src;
   }
   break;
   }
   }
}
function losehighlight(x)
{
   if (set==false)
   {
  	 for (i=1;i<6;i++)
  	 {
  		 document.getElementById(i).src=star1.src;
  		 document.getElementById('vote').innerHTML=""
 	 }
   }
}

function setStar(x)
{
   y=x*1+1
   if (set==false)
   {
   	switch(x)
   {
   case "1": 
   a="1"
   flash(a);
   document.review.rating.value = '1'; 
   break;
   case "2":
   a="2"
   flash(a);
   document.review.rating.value = '2';
   break;
   case "3": 
   a="3"
   flash(a);
   document.review.rating.value = '3';
   break;
   case "4":
   a="4"
   flash(a);
   document.review.rating.value = '4';
   break;
   case "5":
   a="5"
   flash(a);
   document.review.rating.value = '5';
   break;
   }
   set=true;
   }
}
function flash()
{
   y=a*1+1
   switch(v)
   {
   case 0:
   for (i=1;i<y;i++)
   {
   document.getElementById(i).src= star1.src;
   }
   v=1
   setTimeout(flash,200)
   break;
   case 1:
   for (i=1;i<y;i++)
   {
   document.getElementById(i).src= star2.src;
   }
   v=2
   setTimeout(flash,200)
   break;
   case 2:
   for (i=1;i<y;i++)
   {
   document.getElementById(i).src= star1.src;
   }
   v=3
   setTimeout(flash,200)
   break;
   case 3:
   for (i=1;i<y;i++)
   {
   document.getElementById(i).src= star2.src;
   }
   v=4
   setTimeout(flash,200)
   break;
   case 4:
   for (i=1;i<y;i++)
   {
   document.getElementById(i).src= star1.src;
   }
   v=5
   setTimeout(flash,200)
   break;
   case 5:
   for (i=1;i<y;i++)
   {
   document.getElementById(i).src= star2.src;
   }
   v=6
   setTimeout(flash,200)
   break;
   }
}
-->
</script>
</head>
<body>
<div id="main">
<?

// Stores the product sku as a session
$_SESSION['sku'] = $_GET['sku'];

echo "<form name='review' method='post' action='add.php?sku=".$_SESSION['sku']."'>";
?>
<table width="600" border="0">
  <tr>
  <td><span class="style1">Name: </span></td> 
  <td><input type="text" name="name" maxlength="32" /></td>
  </tr>
  <tr>
    <td><span class="style1">Review Title: </span></td>
	<td><input size="51" maxlength="60" type="text" name="reviewtitle" value=""/></td>
  </tr>
  <tr>
    <td><span class="style1">Rating: </span></td>
        <td>
         <body onload="loadStars()">
        <img src="images/staroff.gif" onmouseover="highlight(this.id)" onclick="setStar(this.id)" onmouseout="losehighlight(this.id)" id="1" style="width:12px; height:12px; float:left;" />
		<img src="images/staroff.gif" onmouseover="highlight(this.id)" onclick="setStar(this.id)" onmouseout="losehighlight(this.id)" id="2" style="width:12px; height:12px; float:left;" />
		<img src="images/staroff.gif" onmouseover="highlight(this.id)" onclick="setStar(this.id)" onmouseout="losehighlight(this.id)" id="3" style="width:12px; height:12px; float:left;" />
		<img src="images/staroff.gif" onmouseover="highlight(this.id)" onclick="setStar(this.id)" onmouseout="losehighlight(this.id)" id="4" style="width:12px; height:12px; float:left;" />
		<img src="images/staroff.gif" onmouseover="highlight(this.id)" onclick="setStar(this.id)" onmouseout="losehighlight(this.id)" id="5" style="width:12px; height:12px; float:left;" />
		<div id="vote" style="font-family:arial; color:red;"></div>
        <? echo '<input type="hidden" name="rating">'; ?>
        </body>
		  </td>
  </tr>
  <tr>
    <td><span class="style1">Rating: </span></td>
        <td>
         <body onload="loadStars()">
        <img src="images/staroff.gif" onmouseover="highlight(this.id)" onclick="setStar(this.id)" onmouseout="losehighlight(this.id)" id="1" style="width:12px; height:12px; float:left;" />
		<img src="images/staroff.gif" onmouseover="highlight(this.id)" onclick="setStar(this.id)" onmouseout="losehighlight(this.id)" id="2" style="width:12px; height:12px; float:left;" />
		<img src="images/staroff.gif" onmouseover="highlight(this.id)" onclick="setStar(this.id)" onmouseout="losehighlight(this.id)" id="3" style="width:12px; height:12px; float:left;" />
		<img src="images/staroff.gif" onmouseover="highlight(this.id)" onclick="setStar(this.id)" onmouseout="losehighlight(this.id)" id="4" style="width:12px; height:12px; float:left;" />
		<img src="images/staroff.gif" onmouseover="highlight(this.id)" onclick="setStar(this.id)" onmouseout="losehighlight(this.id)" id="5" style="width:12px; height:12px; float:left;" />
		<div id="vote" style="font-family:arial; color:red;"></div>
        <? echo '<input type="hidden" name="rating1">'; ?>
        </body>
		  </td>
  </tr>
  <tr>
    <td><span class="style1">Comment: </span></td>
    <td><textarea name="comment" cols="57" rows="6"></textarea></td>
  </tr>
  <tr>
  <td></td>
    <td>
      <input type="submit" value="Submit Review" />
    </td>
  </tr>
</table>
</form>
</div>
</body>
</html>

I understand how to modify the rest of the code to insert this into my database but Im not sure how to change this to allow multiple star reviews.

I tried to just copy and paste and change some of the values to no avail.
I contacted the seller of the script and he recommended I ask here.

I appreciate any help. Thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.