2013-01-04 55 views
-1

好的我有一個腳本,每次你評價它都會改變圖像,而且它工作的很好,但問題是人們可以垃圾評級系統,所以我認爲它可以做一些排序包含評級股利之前延遲的顯示出來後的新圖像設置新圖片後div上的延遲

代碼應推遲的RatingBar:

<div id="button" onclick="changeSrc2()"> 
<div class="rate_widget" id="<? echo $id;?>"> 
<div class="star_1 ratings_stars"></div> 
<div class="star_2 ratings_stars"></div> 
<div class="star_3 ratings_stars"></div> 
<div class="star_4 ratings_stars"></div> 
<div class="star_5 ratings_stars"></div> 
<div class="total_votes">vote data</div> 
</div> 
</div> 

代碼的onclick改變評價欄上的圖像:

$number="1"; 
$wrongnumber="2"; 
$random = mysql_query("SELECT * FROM images ORDER BY RAND()"); 
$place="upload/"; 
echo '<script type="text/javascript"> '; 
while($wor = mysql_fetch_array($random)) 
    { 
    $ids=$wor['id']; 
    $name = $wor['name']; 
    $images = $place . $wor['name']; 
    $number=$number + 1; 
    $wrongnumber=$wrongnumber + 1; 
echo 'function ' . 'changeSrc' . $number . '() '; ?> 
{ 
document.getElementById("rand").src="<? echo $images;?>"; 
document.getElementById("button").onclick=changeSrc<? echo $wrongnumber;?>; 
document.getElementsByClassName('rate_widget')[0].id = <? echo $ids;?>; 
} 
<? 
    } 
?> 
</script> 

和代碼,以顯示所述第一圖像:

/*Display images*/ 
$r = mysql_query("SELECT * FROM images ORDER BY RAND() LIMIT 1"); 

while($wor = mysql_fetch_array($r)) 
{ 
    $place="upload/"; 
    $id=$wor['id']; 
    $name = $wor['name']; 
    $image = $place . $wor['name']; 
    echo '<img id="rand" src="'.$image.'" style="max-height:330px;">'; 
} 

回答

0

嘗試使用sleep()功能。它看起來像這樣:

<?php 
sleep(2); 
echo ' 
<div id="button" onclick="changeSrc2()"> 
<div class="rate_widget" id=' . $id . '"> 
<div class="star_1 ratings_stars"></div> 
<div class="star_2 ratings_stars"></div> 
<div class="star_3 ratings_stars"></div> 
<div class="star_4 ratings_stars"></div> 
<div class="star_5 ratings_stars"></div> 
<div class="total_votes">vote data</div> 
</div> 
</div> 
'; 
?>