Bonsoir
Dans un petit formulaire que j ai sur mon je voudrais avoir un select qui ouvre des inputs, j ai un code qui fonctionne parfaitement, sauf que si je choisie 1 le input ce place sous la case select, si je choisi 2 alors 2 input sont bien présent sauf qui a un décalage ainsi de suite, j aimerais qui n est pas ce décalage. Voici le code en question.
Code HTML : Sélectionner tout - Visualiser dans une fenêtre à part
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script language="JavaScript"> function affiche_formulaire() { // Particulier if (document.votre_activite.activite.selectedIndex == 0) document.getElementById('form_particulier').style.visibility = 'visible'; else document.getElementById('form_particulier').style.visibility = 'hidden'; // Association if (document.votre_activite.activite.selectedIndex == 1) document.getElementById('form_association').style.visibility = 'visible'; else document.getElementById('form_association').style.visibility = 'hidden'; // Entreprise if (document.votre_activite.activite.selectedIndex == 2) document.getElementById('form_entreprise').style.visibility = 'visible'; else document.getElementById('form_entreprise').style.visibility = 'hidden'; } </script> </head> <body> <form name="votre_activite" action="" method="post"> <label><strong>Nombre de patineur :</strong></label> <select name="activite" OnChange="affiche_formulaire();"> <option value="particulier">1</option> <option value="association">2</option> <option value="entreprise"> 3</option> </select> <br/> </form> <!-- Particulier --> <span id="form_particulier" style="visibility:text"> <form method="post" action=""> <label><strong>Patineur 1:</strong></label> <input type="text" name="nom_particulier"/><br/> </form></span> <!-- Association --> <span id="form_association" style="visibility:hidden"> <form method="post" action=""> <label><strong>Patineur 1:</strong></label> <input type="text" name="nom_association"/><br/> <label><strong>Patineur 2:</strong></label> <input type="text" name="nom_association"/><br/> </form></span> <!-- Entreprise --> <span id="form_entreprise" style="visibility:hidden"> <form method="post" action=""> <label><strong>Patineur 1:</strong></label> <input type="text" name="nom_particulier"/><br/> <label><strong>Patineur 2:</strong></label> <input type="text" name="nom_association"/><br/> <label><strong>Patineur 3:</strong></label> <input type="text" name="nom_entreprise"/><br/> </form></span> </select> </form> </body> </html>
Merci beaucoup pour votre aide.
Partager