Bonjour,
Dans un formulaire php,je souhaiterai cocher une checkbox, sans rafraichir la page,qui afficher un champ text.
Es ce que c'est possible?
Version imprimable
Bonjour,
Dans un formulaire php,je souhaiterai cocher une checkbox, sans rafraichir la page,qui afficher un champ text.
Es ce que c'est possible?
oui :
coté html :
coté javascript :Code:
1
2 <input type="checkbox" onclick="voirChamps()" /> <input type="text" id="toto" style="display:none"/>
Code:
1
2
3 function voirChamps(){ document.getElementById('toto').style.display = "block"; }
Merci pour vos réponses,
Cependant, j'ai testé dans ma page php, et se n'est pas le résultat que je souhaite.
Le but est :
Lorsque je coche une case, un champ s'affiche, et quand je décoche le champ disparait.
Je voudrais un champ pour chaque case, car dans le code suivant, se n’est pas le cas ; j’ai un champ pour toutes les cases, celui de la première valeur de la table.
Voici mon code
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 <html> <head> <script > function afficher(madiv) { document.getElementById(madiv).style.display =(document.getElementById(madiv).style.display=='none')?'block':'none'; } </script> <?php $odbc = odbc_connect( 'bd_saisi_vic' , 'root' , '') or die ("Impossible de se connecter a la BD") ; $sql9="SELECT * FROM T_vehicule "; $requete9 = odbc_do($odbc,$sql9) or die( odbc_error()); ?> </head> <body> <table width="656" border="0" align="center"> <tr> <td colspan="4" valign="top">Type de vehicule a utiliser :<?php while($tab = odbc_fetch_array($requete9)) {?> </td> </tr> <tr> <td width="225"> </td> <td width="22" height="20" valign="top"> <input type="checkbox" name='selectvehi[]' id="'selectvehi[]'"onclick="afficher('madiv[]')" value="<?php echo $tab['idvehi']; ?>" /></td> <td width="171" valign="top"><?php echo $tab['libelvehi']; ?></td> <td width="210" valign="top"><div id="madiv[]" style="display: none"><input type="text" value="<?php echo $tab['libelvehi']; ?>"></div></td> <?php } ?> </tr> </table> </body> </html>
resolu