Note that there are some explanatory texts on larger screens.

plurals
  1. POjavascript checkbox select all, unselect all, invert selection
    primarykey
    data
    text
    <p>I meet a problem with a script i'm doing. actually I gave something like that because I'm doing a mail box for my intranet. </p> <pre><code>&lt;script type="text/javascript"&gt; function GereChkbox(conteneur, a_faire) { var blnEtat=null; var Chckbox = document.getElementById('box-table-a').firstChild; while (Chckbox!=null) { if (Chckbox.nodeName=="INPUT") if (Chckbox.getAttribute("type")=="checkbox") { blnEtat = (a_faire=='0') ? false : (a_faire=='1') ? true : (document.getElementById(Chckbox.getAttribute("id")).checked) ? false : true; document.getElementById(Chckbox.getAttribute("id")).checked=blnEtat; } Chckbox = Chckbox.nextSibling; } } &lt;/script&gt;&lt;form&gt; &lt;table width="100%" border="0" id='box-table-a'&gt; &lt;tr&gt; &lt;th scope="col" width="15%"&gt;&lt;strong&gt;Exp&amp;eacute;diteur&lt;/strong&gt;&lt;/th&gt; &lt;th scope="col" width="60%"&gt;&lt;strong&gt;Message&lt;/strong&gt;&lt;/th&gt; &lt;th scope="col" width="10%"&gt;&lt;strong&gt;Date&lt;/strong&gt;&lt;/th&gt; &lt;th scope="col" width="15%"&gt;&lt;strong&gt;Actions&lt;/strong&gt;&lt;/th&gt; &lt;/tr&gt;&lt;?php $sql="SELECT * FROM `messages` WHERE `id_destinataire`='".$_SESSION['login']."' AND `trash`='0' ORDER BY id DESC LIMIT ".$premiereEntree.", ".$messagesParPage."" ; $result=mysql_query($sql) or die(__LINE__.mysql_error().$sql); $i=0; while($data=mysql_fetch_assoc($result)) { ?&gt; &lt;tr&gt; &lt;td align="left"&gt;&lt;?php $req="SELECT * FROM `gestionnaire` WHERE `login`='".$data['id_expediteur']."'"; $result2=mysql_query($req) or die(__LINE__.mysql_error().$req); $expediteur=mysql_fetch_assoc($result2); ?&gt;&lt;img src="&lt;?php if (!empty($expediteur['urlavatar'])) {echo $expediteur['urlavatar']; } else {echo "images/noAvatar.gif" ;} ; ?&gt;" width="50px" height="50px" /&gt;&lt;br /&gt;&lt;?php echo $expediteur['nom'].' '.$expediteur['prenom'] ; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php if($data['lu']=='0') { echo '&lt;p align="left"&gt;&lt;img src="images/Gnome-Mail-Unread-32.png" width="24px" height="24px" /&gt;&lt;strong&gt; '.$data['titre'].'&lt;/strong&gt;&lt;/p&gt;'; $nbChar = 150; // Nb. de caractères sans '...' if(strlen($data['message']) &gt;= $nbChar) $message = substr($data['message'], 0, $nbChar).' [...]'; echo '&lt;p align="left"&gt;&lt;i&gt;'.$message.'&lt;/i&gt;&lt;/p&gt;'; } else { echo '&lt;p align="left"&gt;&lt;img src="images/Gnome-Emblem-Mail-32.png" width="24px" height="24px" /&gt;&lt;strong&gt; '.$data['titre'].'&lt;/strong&gt;&lt;/p&gt;'; $nbChar = 150; // Nb. de caractères sans '...' if(strlen($data['message']) &gt;= $nbChar) $message = substr($data['message'], 0, $nbChar).' [...]'; echo '&lt;p align="left"&gt;&lt;i&gt;'.$message.'&lt;/i&gt;&lt;/p&gt;';} ; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo date('d-m-Y H:i',strtotime($data["date"])) ; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;a href="index.php?p=liremessage&amp;amp;id=&lt;?php echo $data['id'] ; ?&gt;"&gt;&lt;img src="images/email_open.png" alt="Lire le message" width="24px" height="24px" border="0" /&gt;&lt;/a&gt; &lt;img src="images/Gnome-Mail-Forward-32.png" alt="Transf&amp;eacute;rer le message" width="24px" height="24px" border="0" /&gt; &lt;a href="deletemessage.page?id=&lt;?php echo $data['id'] ; ?&gt;" onclick="return confirm('Voulez vous vraiment supprimer ce message?')"&gt;&lt;img src="images/mail-trash.png" alt="Supprimer ce message" width="24px" height="24px" border="0" /&gt;&lt;/a&gt; &lt;input type="checkbox" name="action[&lt;?php echo ++$i; ?&gt;]" id="checkbox&lt;?php echo $i; ?&gt;" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;?php } ; ?&gt; &lt;/table&gt; &lt;table width="100%" border="0"&gt; &lt;tr&gt; &lt;td&gt;Actions: &lt;input type="button" value="Tout cocher" onClick="GereChkbox('div_chck','1');"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;input type="button" value="Tout d&amp;eacute;cocher" onClick="GereChkbox('div_chck','0');"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;input type="button" value="Inverser la s&amp;eacute;lection" onClick="GereChkbox('div_chck','2');"&gt;&lt;/td&gt; &lt;td&gt;&amp;nbsp;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; </code></pre> <p>In fact it does not really work because of the script and I have no error messages in the console.</p> <p>Thank you verry much in advance for your help.</p> <p>Kind regards.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload