Ver Mensaje Individual
  #3 (permalink)  
Antiguo 13/01/2009, 18:31
martuanez
 
Fecha de Ingreso: julio-2008
Mensajes: 109
Antigüedad: 15 años, 10 meses
Puntos: 0
Respuesta: Sistema de Votación

Cita:
<html>

<head><style type="text/css">
.starOn{
background-image: url("/images/full-star.gif");
background-repeat: no-repeat;
width: 10px;
height: 10px;
}
.starOff{
background-image: url("/images/clear-star.gif");
background-repeat: no-repeat;
width: 10px;
height: 10px;
}
</style>
<title></title>
</head>

<body>

<?php
include_once("vote.php");

function displayRating($item)
{
echo "<html><div id=\"processingDiv-$item\" style=\"display:none\">""\n";

echo "<img src="ajax-loader.gif"></div>";

echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>\n";
for ($i=1; $i<=10; $i++)
{
if ($i == 1) $class = "starOn"; else $class = "starOff";
echo "<td>\n";
echo "<div class=\"$class\" id=\"ratings-$item-$i\" onmouseout=\"javascript:HoverStars('$item', 1)\" onmouseover='javascript:HoverStars('$item', $i)\" onmouseup=\"javascript:SubmitVote($i, '$item')\"></div>\n";
echo "</td>\n";
}
echo "</tr></table></html>\n";

}

?>
<script type="text/javascript">
function ajaxSubmit(url, processingDiv, targetDiv)
{
targetArea = document.getElementById(targetDiv);
processingArea = document.getElementById(processingDiv);

var xmlHttp;
try
{ xmlHttp=new XMLHttpRequest(); }
catch (e)
{
try
{ xmlHttp=new ActiveXObject('Msxml2.XMLHTTP'); }
catch (e)
{
try
{ xmlHttp=new ActiveXObject('Microsoft.XMLHTTP'); }
catch (e)
{
alert('Your browser does not support AJAX!');
return false;
}
}
}

xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
processingArea.style.display = 'none';
targetArea.innerHTML = xmlHttp.responseText;
}
}

processingArea.style.display = 'block';
xmlHttp.open('GET',url,true);
xmlHttp.send(null);
}

function SubmitVote(vote, item)
{
var poststr = 'vote.php' +
'?item=' + item +
'&vote=' + vote;

LockStars(item, vote);
ajaxSubmit(poststr, 'processingDiv-'+item, 'ratingDiv-'+item);
}

function HoverStars(item, star)
{
var starCount;
for (starCount=1; starCount<=star; starCount++)
document.getElementById('ratings-'+item+'-'+starCount.toString()).className = 'starOn';
for (starCount=star+1; starCount<=10; starCount++)
document.getElementById('ratings-'+item+'-'+starCount.toString()).className = 'starOff';
}

function LockStars(item, star)
{
var starCount;
for (starCount=1; starCount<=star; starCount++)
{
document.getElementById('ratings-'+item+'-'+starCount.toString()).className = 'starOn';
document.getElementById('ratings-'+item+'-'+starCount.toString()).onmouseover = null;
document.getElementById('ratings-'+item+'-'+starCount.toString()).onmouseout = null;
document.getElementById('ratings-'+item+'-'+starCount.toString()).onmouseup = 'javascript:void(0);';
}
for (starCount=star+1; starCount<=10; starCount++)
{
document.getElementById('ratings-'+item+'-'+starCount.toString()).className = 'starOff';
document.getElementById('ratings-'+item+'-'+starCount.toString()).onmouseover = null;
document.getElementById('ratings-'+item+'-'+starCount.toString()).onmouseout = null;
document.getElementById('ratings-'+item+'-'+starCount.toString()).onmouseup = 'javascript:void(0);';
}
}
</script>

</body>

</html>
Arreglé algo de lo que me dijiste pero igual me parece que le estoy errando en algo más, o no entendí bien algo...