Index du Forum » » Le coin des codeurs

Auteur

Cases à cocher (mais pas les 2 en même temps)
bibi
16   

  Posté : 07-07-2003 14:04

voila !! tout est dans le titre !!

En fait je dois gerer une corbeille, et donc j'ai 2 cases à cocher, une pour supprimer et une pour restaurer !!
(et un bouton envoyer avec une boite de confirmation mais ça on s'en fout)
Donc j'aimerai qu'on ne puisse cocher qu'un case à la fois .....et pas les 2.....
Comment faire .....



voici le script si besoin :

<?

$HttpServer="HTTP_HOST";
$host="loc alhost";
$user="root";
$pass="";
$bdd=&quo t;bdplib";
$connexion=mysql_connect($host,$user,$pass) ;
@mysql_select_db($bdd,$connexion);
// sélectionne toutes les fiches de la table $table
$query = "SELECT * FROM informations where Valid='NON' and Supprimer='OUI' and (Type ='Démonstration' or Type ='Demonstration') order by Id ;";
$result = mysql_query($query, $connexion);
/* donne le nombre de ligne d'un resultat*/
$num_rows = mysql_num_rows($result);
if (isset($enregistrer)){

$j=0;

while($j<$num_rows){

/* si la case est cochée echo $HTTP_POST_VARS["check".$j]='on', */
/*et si la case est décochée alors echo $HTTP_POST_VARS["check".$j] n'a pas de valeur*/
if(isset($HTTP_POST_VARS["check".$j])){
$HTTP_ POST_VARS["check1".$j]!='on';
$requete=" delete from informations WHERE Valid='NON' and Supprimer='OUI' and ";
$requete.=" Id=" .$HTTP_POST_VARS["hid".$j] ;
$resultat = mysql_query($requete, $connexion);

}elseif (isset($HTTP_POST_VARS["check1".$j])){
$requete1="update informations set Supprimer='NON' and Valid='NON' where ";
$requete1.=" Id=" .$HTTP_POST_VARS["hid".$j] ;
$result1 = mysql_query($requete1, $connexion);

}
$j++;


}
$res ult = mysql_query($query, $connexion);

$num_rows=mysql_num_rows($result);
}

?& gt;
<html>
<head>
<title>Supprimer démonstration</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<SCRIPT>
function reset_envoyer()
{
//ouvre une boite de confirmation
if (confirm("Etes vous sûr de vouloir supprimer ?")) {
document.form1.submit();
}


function controle_choix(i)
{
var choix = document.form1.check;
if (i == 0)
{
if (choix[0].checked == true)
{
for (i = 1; i < choix.length; i++)
choix[i].checked = false;
}
}
else
{
if (choix[i].checked == true)
{
choix[0].checked = false;
}
}
}

</SCRIPT>

<body bgcolor="#FFFFE1" ALINK="#FF9900" LINK="#FF9900" VLINK="#FF9900">
<FONT FACE="Verdana" SIZE=6 COLOR="#FF8040">
<center> Démonstrations</center></font>
<br><form name="form1" METHOD="POST" ACTION="file:///C|/Program%20Files/EasyPHP/www/plib/admin/supprimer/./supd emo.php?enregistrer=1" >

<?
if ($result) {
If ($num_rows==0) {?>
<center><? echo("Il n'y a pas de nouveaux documents à supprimer");?> </center>

<?} else{ ?>
<center><? echo "Il y a ".$num_rows." nouveaux documents";?> </center>
<br>
<blockquote><blockquote><? /*tabulation*/?>
<? $i=0;?>

<table width="802" border="1">
<? while ($val=mysql_fetch_array($result)){ ?>
<br>
<tr>
<td width="127" height="20" valign="top"><br>
<br><br>

<? $id=$val["Id"] ;?>

<? /* la case à cocher*/?>
<input type="checkbox" name='check<?echo $i;?>' checked > Supprimer
<input type="hidden" name='hid<?echo $i;?>' value=<?echo $id ;?>>
<? $i++; ?>
</td>

<td width="119" height="20" valign="top"><br>
<br><br>

<? /* la case à cocher*/?>
<input type="checkbox" name='check1<?echo $i;?>' onclick="controle_choix()" > Restaurer


</td>
<td width="534" valign="top"> <br>
<LI>

<? If ($val["NameTitle"] != "") { ?>
<font face="Verdana" size=3 color="#FF8040"><b>
<? echo $val["NameTitle"]; ?>
</b></font><br>
<? } ?>

<? If ($val["Organization"]!=""){ ?>
<font face="Verdana" size=1 color="#0000FF"><b> Organisation : </b>
<? echo $val["Organization"];?>
</font><br>
<? } ?>

<? If ($val["Abstract"]!="") { ?>
<FONT FACE="Verdana" size=1 COLOR="#0000FF"><b> Résumé : </b>
<? echo $val["Abstract"];?></font><br>
<? } ?>

<? If ($val["Description"]!="") {?>
<FONT FACE="Verdana" size=1 COLOR="#0000FF"> <b>Description : </b>
<FONT FACE="Verdana" size=1 COLOR="#0000FF">
<A HREF="#" onclick="window.open('<? echo $val["Description"];?>','description','width=380,height=270,toolba r=no,,menubar=no,scrollbars=yes,resizable=no')">
<? echo $val["Description"];?></a></font></font><br&g t;
<? } ?>

<? If ($val["Keywords"]!=""){ ?>
<FONT FACE="Verdana" size=1 COLOR="#0000FF"><b>Keywords: </b>

<? echo $val["Keywords"];?></font><br>
<? } ?>

<? If ($val["URL"]!=""){ ?>
<? if (strpos($val["URL"],$httpserver) ){?>
<font face="Verdana" size=1 color="#0000FF"><b> URL : </b>
<a href="<? echo $val["URL"] ;?>" target="nwindow">
<? echo $val["URL"]; ?></a> </font><br>
<? } else { ?>
<font face="Verdana" size=1 color="#0000FF"><b> URL : </b>
<a href="<? echo $val["URL"];?>" target="nwindow">
<? echo $val["URL"];?></a> </font><br>
<? }?>
<? } ?>

<? If ($val["Contact"]!=""){ ?>
<FONT FACE="Verdana" size=1 COLOR="#0000FF"><b>Contact: </b>
<? echo $val["Contact"];?></font><br>
<? } ?>

<? If ($val["Email"]!=""){ ?>
<font face="Verdana" size=1 color="#0000FF"><b> E-mail :</b> <a href="mailto:'"&<? echo $val["Email"];?>&"'"><? echo $val["Email"];?></a><br></font>
<? } ?>

<? If ($val["Langue"]!=""){ ?>
<font face="Verdana" size=1 color="#0000FF"><b> Langue: </b>
<? echo $val["Langue"];?> </font><br>
<? } ?>
<? } ?>
<br>
</td>
</tr>
</table>
<br><br>

<?$val=mysql_result($result,$num_rows>$num=$num_rows);?>

<center><input type="Button" name="Button" value="Enregistrer les modifications" onclick="reset_envoyer()" ></center>

<? } ?>
<? } ?>

</blockquote></blockquote>
</form>
</body>

</html>



Cet article provient de NPDS

http://www.npds.org/viewtopic.php?topic=6536&forum=5