30/01/2011, 17h48
|
#3
|
|
Membre du Club
Inscription : janvier 2007 Messages : 410 Détails du profil  Informations forums : Inscription : janvier 2007 Messages : 410 Points : 56 Points : 56
|
Citation:
Envoyé par vermine
Bonjour,
Dans la fonction de retour du call Ajax, vous pouvez en profiter pour cacher/bloquer votre bouton.
|
Et comment faire afin de les afficher caches, j'ai procede a un autre exemple:
comment.php:
Code :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
<head>
<script type="text/javascript">
function ajax(page,divAMettreAJour){
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById(divAMettreAJour).innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET",page,true);
xmlhttp.send();
}
</script>
</head>
<body>
echo '<input type="button" id="LikeId" value="Oui" onclick="ajax(\'page.php?thumbs=up&idcom='.$idcom.'&menu='.$menu.'&idm='.$idm.'\',\'up'.$idcom.'\')"/><span id="up'.$idcom.'"> '.$datau[0].' </span>';
echo ' ';
echo '<input type="button" id="DisLikeId" value="Non" onclick="ajax(\'page.php?thumbs=down&idcom='.$idcom.'&menu='.$menu.'&idm='.$idm.'\',\'down'.$idcom.'\')"><span id="down'.$idcom.'"> '.$datad[0].' </span>';
</body> |
page.php:
Code :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js"></script>
<script>
$(document).ready(function(){
$(".VotingButtomClass").click(function()
{
var This_id = $(this).attr("id");
$(this).attr("disabled",true);
});
});
</script>
</head>
<body>
<?php
mysql_select_db($db_general) or die ('Erreur de selection de la BD general: '.mysql_error());
if ($thumbs == 'up')
{
$updateu = 'INSERT INTO thumbs VALUES ("", "'.$idcom.'", "'.$idpseudo.'", "1", "0","'.$ip_visiteur.'", "'.$MakkaDateTime.'")';
//echo $updateu.'<br>';
$queryu = mysql_query($updateu) OR DIE (mysql_error());
$selects = 'SELECT count(thumbsu) FROM thumbs WHERE idcom= "'.$idcom.'" AND thumbsu !="0"';
}
if ($thumbs == 'down')
{
$updated = 'INSERT INTO thumbs VALUES ("", "'.$idcom.'", "'.$idpseudo.'", "0", "1","'.$ip_visiteur.'", "'.$MakkaDateTime.'")';
//echo $updated.'<br>';
$queryd = mysql_query($updated) OR DIE (mysql_error());
$selects = 'SELECT count(thumbsd) FROM thumbs WHERE idcom= "'.$idcom.'" AND thumbsd !="0"';
}
echo '<span id="displayhere"></span>';
$results = mysql_query ($selects) or die ('Erreur de thumbsdown: ' .mysql_error());
$datas = mysql_fetch_array($results);
//echo $datas[0];
echo '<input type="button" id="LikeId" class="VotingButtomClass" value="Oui"/><span id="up'.$idcom.'"> '.$datas[0].' </span>';
echo ' ';
echo '<input type="button" id="DisLikeId" class="VotingButtomClass" value="Non"><span id="down'.$idcom.'"> '.$datas[0].' </span>';
?> |
le resultat est:
|
|
00
|