hello
voici mon souci:
j'ai un formulaire pour un loto avec des boutons radios personaliser.
Quand l'utilisateur selectionne un boule et dois changer de couleur ( avec une autre image ) le souci c'est que la boule change bien de couleur mais n'est plus compter dans les 5 boule maximum et une fois plus selectioner elle ne change plus de couleur.
Pouvez vous m'aider car je ne vois pas ou est la faute.
voici le code
<?php
echo "<html><head>";
?>
<style type="text/css">
label
{
padding-right : 3px;
margin-right : 3px;
background : #fc6;
vertical-align : top;
}
#conteneurRadio p
{
position : relative;
float : left;
margin : 0;
}
#conteneurRadio input
{
opacity : 0; /* for !IE */
filter : alpha(opacity=0); /* for IE */
width : 20px;
height : 20px;
position : absolute;
right : 0;
top : 0;
}
#conteneurCheckbox p
{
position : relative;
float : left;
margin : 0;
}
#conteneurCheckbox input
{
opacity : 0; /* for !IE */
filter : alpha(opacity=0); /* for IE */
width : 20px;
height : 20px;
position : absolute;
right : 0;
top : 0;
}
</style>
<!--// formulaire -->
<script type="text/javascript">
<!--//checkbox loto avec limite 5 script-->
//initial checkCount of zero
var checkCountb=0
//maximum number of allowed checked boxes
var maxChecksb=5
function setChecksb(obj){
//increment/decrement checkCount
if(obj.checked){
checkCountb=checkCountb+1
}else{
checkCountb=checkCountb-1
}
//if they checked a 5th box, uncheck the box, then decrement checkcount and pop alert
if (checkCountb>maxChecksb){
obj.checked=false
checkCountb=checkCountb-1
alert(+maxChecksb+' boules MAX')
}
}
//initial checkCount of zero
var checkCount=0
//maximum number of allowed checked boxes
var maxChecks=2
function setChecks(obj){
//increment/decrement checkCount
if(obj.checked){
checkCount=checkCount+1
}else{
checkCount=checkCount-1
}
//if they checked a 3th box, uncheck the box, then decrement checkcount and pop alert
if (checkCount>maxChecks){
obj.checked=false
checkCount=checkCount-1
alert(+maxChecks+' étoiles MAX')
}
}
//radio 1
function turnImgRadio(objRadio)
{
var t_img = document.getElementById('conteneurRadio').getElementsByTagName('img');
for (var i = 0; i < t_img.length; i++)
{
t_img[i].src = 'http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule1.png';
}
var img = document.getElementById('img_radio_' + objRadio.id);
img.src = 'http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boulesb1.png';
}
//radio 2
function turnImgRadio2(objRadio)
{
var t_img = document.getElementById('conteneurRadio').getElementsByTagName('img');
for (var i = 0; i < t_img.length; i++)
{
t_img[i].src = 'http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule2.png';
}
var img = document.getElementById('img_radio_' + objRadio.id);
img.src = 'http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boulesb2.png';
}
</script>
<?
echo "</head><body>";
global $my;
echo "<b><u>";
echo "Bonjour ";
echo "</b></u>";
$user =& JFactory::getUser();
$my=$user->get('username');
echo "<b><u>";
echo $my;
echo "</b></u>";
//*********************************************************************************************
//*******************************CONNEXION A LA BASE DE DONNEES********************************
//*********************************************************************************************
$connexion = mysql_connect('localhost','','');
if ($connexion>0)
{
//echo "Connexion effectuée<br>";
}
else {
echo "Pas de connexion active";
exit;
}
//echo"<br>" ;
//*********************************************************************************************
//*****************************SELECTION DE LA BASE DE DONNEE "infos"***************************
//*********************************************************************************************
if (!mysql_select_db('',$connexion))
{
echo "Erreur de sélection BDD" ;
exit ;
}
else
{
//echo "Selection de la base effectuée<br>";
}
//*********************************************************************************************
//****************************MISE EN PLACE DE LA REQUETE SQL***********************************
//*********************************************************************************************
$sql="SELECT MAX(num) FROM jos_loto_tirage"; //récupère le dernier tirage
//*********************************************************************************************
//***************************EXECUTION DE LA LA REQUETE*****************************************
//*********************************************************************************************
$resultat=mysql_query($sql,$connexion);
//*********************************************************************************************
//*******************EXTRACTION DES DONNEES DE LA REQUETE POUR EVITER LE PLANTAGE BECAUSE PAS DE DONNEES**
//*********************************************************************************************
// Vérification du résultat
// Ceci montre la requête envoyée à MySQL ainsi que l'erreur. Utile pour déboguer.
if (!$resultat) {
$message = "Requête invalide : " . mysql_error() . "\n";
$message .= "Requête complète : " . $query;
die($message);
}
//*********************************************************************************************
//*******************FIN EXTRACTION ***********************************************************
//*********************************************************************************************
$ligne=mysql_fetch_array($resultat);
extract($ligne);
//printf(" num tirage max : %s", $ligne[0]);
$max_id_tirage=$ligne[0];
//while($ligne=mysql_fetch_array($resultat))
// {
// extract($ligne);
// printf(" num tirage max : %s", $ligne[0]);
// }
//*********************************************************************************************
//****************************MISE EN PLACE DE LA REQUETE SQL***********************************
//*********************************************************************************************
$sql="SELECT MAX(num_tirage) FROM jos_loto_joueurs where username='$my'"; //récupère le dernier jeu du joueur
//*********************************************************************************************
//***************************EXECUTION DE LA LA REQUETE*****************************************
//*********************************************************************************************
$resultat=mysql_query($sql,$connexion);
//*********************************************************************************************
//*******************EXTRACTION DES DONNEES DE LA REQUETE POUR EVITER LE PLANTAGE BECAUSE PAS DE DONNEES**
//*********************************************************************************************
// Vérification du résultat
// Ceci montre la requête envoyée à MySQL ainsi que l'erreur. Utile pour déboguer.
if (!$resultat) {
$message = "Requête invalide : " . mysql_error() . "\n";
$message .= "Requête complète : " . $query;
die($message);
}
//*********************************************************************************************
//*******************FIN EXTRACTION ***********************************************************
//*********************************************************************************************
$ligne=mysql_fetch_array($resultat);
extract($ligne);
//printf(" num tirage max joueur : %s", $ligne[0]);
$max_id_tirage_joueur=$ligne[0];
//while($ligne=mysql_fetch_array($resultat))
// {
// extract($ligne);
// printf(" num tirage max : %s", $ligne[0]);
// }
if ($max_id_tirage_joueur==$max_id_tirage+1)//tu as dejà joué
{
echo '<br><br>Tu as déjà joué au tirage numéro '.$max_id_tirage_joueur.' attends le prochain tirage';
}
else //tu n'as pas encore joué
{
//*********************************************************************************************
//*******************ON LUI DEMANDE CES NUMEROS************************************************
//*********************************************************************************************
//echo "<form name='form".$i."' action='modifier.php' method='post'>";
//echo "<input type=\"hidden\" value=\"".$i."\" name=\"mon_champ_cache\">";
//echo "<button type='submit' action='modifier.php' name=\"bouton\" value=".$row_array[$i]."'>";
//echo "<img src='../images/modifier.png'>";
//echo "</button>";
//echo "</form>";
//*********************************************************************************************
//****************************FERMETURE DE LA BASE DE DONNEES***********************************
//*********************************************************************************************
//mysql_close($connexion);
$tirage = $max_id_tirage + 1;
echo "<br>Valide ta grille pour le tirage numéro ".$tirage;
echo "<br><br>";
echo "<p><u><b>Sélectionnez vos 5 numéros:</b><u></p><br>";
if(!empty($_POST["boules"])) {
echo "<b>";
for ($i = 0; $i < count($_POST["boules"]); $i++)
echo $_POST["boules"][$i]." - ";
echo "</b><br><br>";
}
echo '<table><form action="http://localhost/senkosta/index.php?option=com_valide&view=valide" id="loto" name="loto" method="POST" >';
echo '<tr>';
echo '<fieldset id="conteneurRadio"><td><input type="radio" name="boule" id="boule" value="1" onclick="turnImgRadio(this)" /><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule1.png" id="img_radio_boule" alt="" /></td></fieldset>';
echo '<fieldset id="conteneurRadio"><td><input type="radio" name="boule1" id="boule" value="2" onclick="turnImgRadio2(this)"/><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule2.png" id="img_radio_boule2" alt=""></td></fieldset>';
echo '<fieldset id="conteneurRadio"><td><input type="radio" name="boule2" id="boule" value="3" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule3.png"><br /></td></fieldset>';
echo '<fieldset id="conteneurRadio"><td><input type="radio" name="boule" id="boule4" value="4" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule4.png"><br /></td></fieldset>';
echo '<td><input type="radio" name="boule5" id="boule5" value="5" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule5.png"><br /></td>';
echo '<td><input type="radio" name="boule6" id="boule6" value="6" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule6.png"><br /></td>';
echo '<td><input type="radio" name="boule7" id="boule7" value="7" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule7.png"><br /></td>';
echo '<td><input type="radio" name="boule8" id="boule8" value="8" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule8.png"><br /></td>';
echo '<td><input type="radio" name="boule9" id="boule9" value="9" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule9.png"><br /></td>';
echo '<td><input type="radio" name="boule10" id="boule10" value="10" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule10.png"><br /></td>';
echo '</tr>';
echo '<tr>';
echo '<td><input type="checkbox" name="boule11" id="boule11" value="11" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule11.png"><br /></td>';
echo '<td><input type="checkbox" name="boule12" id="boule12" value="12" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule12.png"><br /></td>';
echo '<td><input type="checkbox" name="boule13" id="boule13" value="13" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule13.png"><br /></td>';
echo '<td><input type="checkbox" name="boule14" id="boule14" value="14" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule14.png"><br /></td>';
echo '<td><input type="checkbox" name="boule15" id="boule15" value="15" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule15.png"><br /></td>';
echo '<td><input type="checkbox" name="boule16" id="boule16" value="16" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule16.png"><br /></td>';
echo '<td><input type="checkbox" name="boule17" id="boule17" value="17" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule17.png"><br /></td>';
echo '<td><input type="checkbox" name="boule18" id="boule18" value="18" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule18.png"><br /></td>';
echo '<td><input type="checkbox" name="boule19" id="boule19" value="19" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule19.png"><br /></td>';
echo '<td><input type="checkbox" name="boule20" id="boule20" value="20" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule20.png"><br /></td>';
echo '</tr>';
echo '<tr>';
echo '<td><input type="checkbox" name="boule21" id="boule21" value="21" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule21.png"><br /></td>';
echo '<td><input type="checkbox" name="boule22" id="boule22" value="22" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule22.png"><br /></td>';
echo '<td><input type="checkbox" name="boule23" id="boule23" value="23" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule23.png"><br /></td>';
echo '<td><input type="checkbox" name="boule24" id="boule24" value="24" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule24.png"><br /></td>';
echo '<td><input type="checkbox" name="boule25" id="boule25" value="25" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule25.png"><br /></td>';
echo '<td><input type="checkbox" name="boule26" id="boule26" value="26" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule26.png"><br /></td>';
echo '<td><input type="checkbox" name="boule27" id="boule27" value="27" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule27.png"><br /></td>';
echo '<td><input type="checkbox" name="boule28" id="boule28" value="28" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule28.png"><br /></td>';
echo '<td><input type="checkbox" name="boule29" id="boule29" value="29" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule29.png"><br /></td>';
echo '<td><input type="checkbox" name="boule30" id="boule30" value="30" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule30.png"><br /></td>';
echo '</tr>';
echo '<tr>';
echo '<td><input type="checkbox" name="boule31" id="boule31" value="31" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule31.png"><br /></td>';
echo '<td><input type="checkbox" name="boule32" id="boule32" value="32" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule32.png"><br /></td>';
echo '<td><input type="checkbox" name="boule33" id="boule33" value="33" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule33.png"><br /></td>';
echo '<td><input type="checkbox" name="boule34" id="boule34" value="34" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule34.png"><br /></td>';
echo '<td><input type="checkbox" name="boule35" id="boule35" value="35" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule35.png"><br /></td>';
echo '<td><input type="checkbox" name="boule36" id="boule36" value="36" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule36.png"><br /></td>';
echo '<td><input type="checkbox" name="boule37" id="boule37" value="37" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule37.png"><br /></td>';
echo '<td><input type="checkbox" name="boule38" id="boule38" value="38" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule38.png"><br /></td>';
echo '<td><input type="checkbox" name="boule39" id="boule39" value="39" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule39.png"><br /></td>';
echo '<td><input type="checkbox" name="boule40" id="boule40" value="40" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule40.png"><br /></td>';
echo '</tr>';
echo '<tr>';
echo '<td><input type="checkbox" name="boule41" id="boule41" value="41" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule41.png"><br /></td>';
echo '<td><input type="checkbox" name="boule42" id="boule42" value="42" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule42.png"><br /></td>';
echo '<td><input type="checkbox" name="boule43" id="boule43" value="43" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule43.png"><br /></td>';
echo '<td><input type="checkbox" name="boule44" id="boule44" value="44" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule44.png"><br /></td>';
echo '<td><input type="checkbox" name="boule45" id="boule45" value="45" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule45.png"><br /></td>';
echo '<td><input type="checkbox" name="boule46" id="boule46" value="46" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule46.png"><br /></td>';
echo '<td><input type="checkbox" name="boule47" id="boule47" value="47" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule47.png"><br /></td>';
echo '<td><input type="checkbox" name="boule48" id="boule48" value="48" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule48.png"><br /></td>';
echo '<td><input type="checkbox" name="boule49" id="boule49" value="49" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule49.png"><br /></td>';
echo '<td><input type="checkbox" name="boule50" id="boule50" value="50" onclick="setChecksb(this)" /></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/boule50.png"><br /></td>';
echo '</tr>';
echo '</table>';
echo '<br><p><u><b>Sélectionnez vos 2 étoiles:</b></u></p><br>';
echo '<table valign="middle">';
echo '<tr>';
echo '<td><input type="checkbox" name="etoile1" id="etoile1" value="1" onclick="setChecks(this)"/></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/etoile1.jpg"><br /></td>';
echo '<td><input type="checkbox" name="etoile2" id="etoile2" value="2" onclick="setChecks(this)"/></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/etoile2.jpg"><br /></td>';
echo '<td><input type="checkbox" name="etoile3" id="etoile3" value="3" onclick="setChecks(this)"/></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/etoile3.jpg"><br /></td>';
echo '<td><input type="checkbox" name="etoile4" id="etoile4" value="4" onclick="setChecks(this)"/></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/etoile4.jpg"><br /></td>';
echo '<td><input type="checkbox" name="etoile5" id="etoile5" value="5" onclick="setChecks(this)"/></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/etoile5.jpg"><br /></td>';
echo '<td><input type="checkbox" name="etoile6" id="etoile6" value="6" onclick="setChecks(this)"/></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/etoile6.jpg"><br /></td>';
echo '<td><input type="checkbox" name="etoile7" id="etoile7" value="7" onclick="setChecks(this)"/></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/etoile7.jpg"><br /></td>';
echo '<td><input type="checkbox" name="etoile8" id="etoile8" value="8" onclick="setChecks(this)"/></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/etoile8.jpg"><br /></td>';
echo '<td><input type="checkbox" name="etoile9" id="etoile9" value="9" onclick="setChecks(this)"/></td><td><img src="http://localhost/senkosta/components/com_loto/views/loto/tmpl/images/etoile9.jpg"><br /></td>';
echo '</tr>';
echo '</table>';
echo '<table>';
echo '<tr><TD><INPUT type="submit" name="Valider" value="Valider"> </TD></tr>';
echo '</table>';
echo '</form>';
echo '<br>';
}
echo '</body>';
echo '</html>';
?>
fred