Bonjour,
J'ai récupéré ce code qui marche très bien mais je voudrais qu'il m'affiche au chargement de la page au moins un champ texte par défaut car actuellement aucun n'apparait sauf en cliquant sur le bouton.
Merci d'avance.
Code : 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 <script type="text/javascript"> var c,c2, ch; // ajoute function plus(){ c=document.getElementById('cadre'); c2=c.getElementsByTagName('input'); ch=document.createElement('input'); ch.setAttribute('type','text'); ch.setAttribute('name','ch[]'+c2.length); ch.setAttribute('style','margin-top:10px; width:350px;'); c.appendChild(ch); document.getElementById('sup').style.display='inline'; } // supprime function moins(){ if(c2.length>0){c.removeChild(c2[c2.length-1])} if(c2.length==0){document.getElementById('sup').style.display='none'}; } </script> <div id="cadre" style="margin-left:0;width:200px"> </div> <br /><p> <input type="button" class="button" value="Ajouter une release" onclick="plus()" /> <input type="button" class="button" style="display:none" id="sup" value="Supprimerun champ" onclick="moins()" /> </p><font color="red">Cliquez autant de fois sur le bouton pour ajouter un champ.</font>
Partager