IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

JavaScript Discussion :

Ajouter des champs dans un formulaire


Sujet :

JavaScript

  1. #1
    Membre à l'essai
    Inscrit en
    Avril 2008
    Messages
    9
    Détails du profil
    Informations forums :
    Inscription : Avril 2008
    Messages : 9
    Points : 10
    Points
    10
    Par défaut Ajouter des champs dans un formulaire
    bonjour je suis débutant en java script je voulais savoir comment je peut rajouter un tableau ou il y a un formulaire en dessous de ce dernier a chaque fois que je clique sur un bouton ajouter
    (j'ai un tableau ou il y a des champ texte en bas du tableau j'ai un bouton ajouter si je clique sur se bouton le même tableau avec les même champs se rajoutent en bas et pareil pour se tableau avec un bouton ajouter ...) merci
    voila le code :
    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
    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
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    <html>
    <head>
    <link rel="stylesheet" type="text/css" href="images/style.css">
    <script language="JavaScript">
    function verif_formulaire()
    {
    var msg="";
    var i=0;
     
    if (document.form1_fr.nom.value.length<1)
    {msg+="- veuillez saisir le nom du produit !!! \n";i++;}
    if (document.form1_fr.nbr.value*0 !=0)
    {msg+="- les carcatères saisie dans le champ nombre de composants doivent être numérique !!! \n";i++;}
    else if (document.form1_fr.nbr.value.length<1)
    		{msg+="- veuillez saisir le nombre de composants !!! \n";i++;}
    if(i==1)
    {
    alert("vous avez une erreur :\n"+msg);
    return false;}
    else if(i>0)
    {alert("vous avez "+i+" erreurs :\n"+msg);
     return false;}
    else
    {document.form1_fr.submit();}
    }
    </script>
     
    <title>ihsen</title>
    <style type="text/css">
    <!--
    .Style20 {font-size: 5pt}
    .Style21 {
    	font-size: 9pt;
    	font-weight: bold;
    }
    -->
    </style>
    </head>
    <body class="PageBODY" background="images/bg.gif">
    <map name="haut">
      <area shape="rect" coords="380,36,489,63" href="aide.htm">
      <area shape="rect" coords="506,36,613,64" href="form1_fr.html">
      <area shape="rect" coords="629,37,742,65" href="form1_cdv.html">
    </map>
     
     
    <table align="center" border="0" cellpadding="0" cellspacing="0" width="760">
    <tbody><tr><td colspan="5"><img src="img/fr_top_ie.JPG" usemap="#haut" border="0" height="69" width="760"></td>
    </tr>
    <tr><td colspan="5"><img src="images/barre_2.gif" height="2" width="760"></td></tr>
    <tr>
    	<td><img src="images/pix.gif" height="1" width="10"></td>
    	<td bgcolor="#0099cc"><img src="images/pix.gif" height="1" width="1"></td>
    	<td bgcolor="#00c0ff"><img src="images/pix.gif" height="1" width="738"></td>
    	<td bgcolor="#0099cc"><img src="images/pix.gif" height="1" width="1"></td>
    	<td><img src="images/pix.gif" height="1" width="10"></td>
     
    </tr>
    <tr>
    	<td><img src="images/pix.gif" height="" width="10"></td>
    	<td bgcolor="#0099cc"><img src="images/pix.gif" height="1" width="1"></td>
    	<td bgcolor="#0099CC">
     
    <table width="738" height="440" border="0" cellpadding="0" cellspacing="0" bgcolor="#00C0FF">
    <tbody><tr>
    <td align="center" valign="top">
     
    <!--<form action='' method="post" name="form1_fr" onSubmit="return verif_formulaire();">-->
    <table width="716" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#ccffff">
      <tbody>
        <tr bgcolor="#0099cc">
          <td width="158" height="24"><img src="images/miss_sf_1.gif"> </td>
          </tr>
     
          <tr>
            <td height="46">
    		<div>
    		<form action='' method="post" name="form1_fr" onSubmit="return verif_formulaire();">
    		<table width="713" border="1">
              <tr>
                <td width="169"><div align="center" class="formcaption">
                  <div align="center"><strong>Nom du produit </strong></div>
                </div></td>
                <td width="152"><div align="left">
                  <input name="nom" size="20" value="" class="champ" type="text" maxlength="20">
                </div></td>
                <td width="155"><div align="center" class="formcaption">
                  <div align="center"><strong>Nombre de composants</strong></div>
                </div></td>
                <td width="209"><div align="center" class="formcaption">
                  <div align="left">
                    <div align="center" class="formcaption">
                      <div align="left">
                        <input name="nbr" size="10" value="" class="champ" type="text" maxlength="2">
                      </div>
                    </div>
                  </div>
                </div></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
            </table>
    		</form>
    		</div>
    		</td>
          </tr>
     
          <tr>
            <td height="18" class="formcaption Style20">&nbsp;</td>
          </tr>
          <tr>
            <td height="18" class="formcaption Style20">
    		<div>
    		<form action='' method="post" name="form2_fr" onSubmit="return verif_formulaire();">
    		<table width="715" border="1">
              <tr>
                <td width="136">&nbsp;</td>
                <td width="136"><div align="left" class="formcaption">
                  <div align="left"><strong>Impact materiaux </strong></div>
                </div></td>
                <td width="145">&nbsp;</td>
                <td width="127"><div align="center" class="formcaption">
                  <div align="left">
                    <div align="center" class="formcaption">
                      <div align="center" class="formcaption">
                        <div align="center" class="formcaption">
                          <div align="center" class="formcaption">
                            <div align="center" class="formcaption"> <strong>R&eacute;utilisation </strong></div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div></td>
                <td width="137"><div align="left">
                  <input name="retu" type="text" class="champ" value="" size="10" maxlength="5">
                </div></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td><div><span class="formcaption">
                  <input name="mat" type="text" class="champ" value="" size="10" maxlength="5">
                </span></div></td>
                <td>&nbsp;</td>
                <td><div align="center" class="formcaption">
                  <div align="left">
                    <div align="center" class="formcaption">
                      <div align="center" class="formcaption">
                        <div align="center" class="formcaption">
                          <div align="center" class="formcaption">
                            <div align="center"><strong>Recyclage</strong></div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div></td>
                <td><div align="left">
                  <input name="recy" type="text" class="champ" value="" size="10" maxlength="5">
                </div></td>
              </tr>
              <tr>
                <td><div align="left"><font class="formcaption"><strong>Composant</strong></font></div></td>
                <td><div align="center" class="formcaption">
                  <div align="left" class="formcaption"><strong>Impact assemblage </strong></div>
                </div></td>
                <td><div align="center" class="formcaption">
                  <div align="center" class="formcaption">
                    <div align="center" class="formcaption">
                      <div align="center" class="formcaption">
                        <div align="center" class="formcaption">
                          <div align="center" class="formcaption">
                            <div align="center" class="Style21">Impact de fin de vie : </div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div></td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td><div align="center" class="formcaption">
                  <div align="left">
                    <input name="comp1" size="20" value="" class="champ" type="text" maxlength="10">
                  </div>
                </div></td>
                <td><div><span class="formcaption">
                  <input name="ass" type="text" class="champ" value="" size="10" maxlength="5">
                </span></div></td>
                <td>&nbsp;</td>
                <td><div align="center" class="formcaption">
                  <div align="center" class="formcaption">
                    <div align="center" class="formcaption">
                      <div align="center" class="formcaption">
                        <div align="center" class="formcaption">
                          <div align="center" class="formcaption">
                            <div align="center" class="formcaption"> <strong>R&eacute;manufacturing</strong></div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div></td>
                <td><div align="left">
                  <input name="rema" type="text" class="champ" value="" size="10" maxlength="5">
                </div></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td><div align="left" class="formcaption"><strong>Impact distribution </strong></div></td>
                <td>&nbsp;</td>
                <td><div align="center" class="formcaption">
                  <div align="left">
                    <div align="center" class="formcaption">
                      <div align="center" class="formcaption">
                        <div align="center" class="formcaption">
                          <div align="center" class="formcaption">
                            <div align="center"><strong>Incin&eacute;ration</strong></div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div></td>
                <td><div align="left">
                  <input name="inci" type="text" class="champ" value="" size="10" maxlength="5">
                </div></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td><div align="center" class="formcaption">
                  <div align="left">
                    <input name="dis" type="text" class="champ" value="" size="10" maxlength="5">
                  </div>
                </div></td>
                <td>&nbsp;</td>
                <td><div align="center" class="formcaption">
                  <div align="left">
                    <div align="center" class="formcaption">
                      <div align="center" class="formcaption">
                        <div align="center" class="formcaption">
                          <div align="center" class="formcaption">
                            <div align="center"><strong>Enfouissement</strong></div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div></td>
                <td><div align="left"><span class="formcaption">
                  <input name="enfo" type="text" class="champ" value="" size="10" maxlength="5">
                </span></div></td>
              </tr>
              <tr>
                <td><input type="button" onClick="" value="Ajouter un composant"/></td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
            </table>
    		</form>
    		</div>
    		</td>
          </tr>
          <tr>
    	    <td height="18" class="formcaption Style20">&nbsp;</td>
          </tr>
          <tr>
          <td height="18" class="formcaption Style20"><p>&nbsp;</p>
            <p>&nbsp;</p></td>
        </tr>
        <tr>
    	<div>
    	<form action='' method="post" name="form3_fr" onSubmit="return verif_formulaire();">
          <td height="18" class="formcaption Style20"> <div align="center">
                           <input name="envoi" type="image" id="Valider" value="Envoyer" src="images/bsearch.gif">
              </p>
          </div></td>
    	  </form>
    	  </div>
        </tr>
        <tr bgcolor="#0099cc">
          <td height="20"><img src="images/pix.gif" height="20" width="10"></td>
          </tr>
      </tbody>
    </table>
    <!--</form>-->
    <p align="center">&nbsp;</p>
      </td>
    </tr>
    </tbody></table>
    	</td>
    	<td bgcolor="#0099cc"><img src="images/pix.gif" height="1" width="1"></td>
    	<td><img src="images/pix.gif" height="1" width="10"></td>
    </tr>
    <tr>
    	<td><img src="images/pix.gif" height="1" width="10"></td>
    	<td colspan="3" valign="top">
     
    	<table border="0" cellpadding="0" cellspacing="0" width="740">
    	<tbody><tr>
    		<td valign="bottom" width="20"><img src="images/fr_footer_coin_annu.gif" height="35" width="20"></td>
    		<td align="center" bgcolor="#0099cc" width="720"><font class="linkm">
    		<a href="mailto:ihsen10481@hotmail.com" class="linkm">Réclamations/Suggestions</a></font></td>
    	</tr>
    	</tbody></table>
    	</td>
    	<td><img src="images/pix.gif" height="1" width="10"></td>
    </tr>
     
    <tr><td colspan="5" align="center"><img src="images/pix.gif" height="3" width="1"></td></tr>
     
    <tr><td height="0" colspan="5" align="center"><font> <a href="http://www.g-scop.inpg.fr/"><img src="img/img_1174574141343.JPG" width="81" height="35" border="0" align="absmiddle"></a></font></td>
    </tr>
     
    </tbody></table>
     
    </body></html>

  2. #2
    Rédacteur/Modérateur

    Avatar de SpaceFrog
    Homme Profil pro
    Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Inscrit en
    Mars 2002
    Messages
    39 640
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 74
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2002
    Messages : 39 640
    Points : 66 663
    Points
    66 663
    Billets dans le blog
    1
    Par défaut
    As tu été jeter un oeil dans la FAQ javascript ?

  3. #3
    Expert éminent sénior
    Avatar de Auteur
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    7 650
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 7 650
    Points : 11 142
    Points
    11 142
    Par défaut
    voir également ce tutoriel

  4. #4
    Rédacteur/Modérateur

    Avatar de SpaceFrog
    Homme Profil pro
    Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Inscrit en
    Mars 2002
    Messages
    39 640
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 74
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2002
    Messages : 39 640
    Points : 66 663
    Points
    66 663
    Billets dans le blog
    1

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Ajouter + supprimer - des champs dans un formulaire
    Par tmedtcom dans le forum Général JavaScript
    Réponses: 3
    Dernier message: 09/05/2012, 10h20
  2. Ajouter des champs dans un formulaire
    Par tic_tac dans le forum Général JavaScript
    Réponses: 4
    Dernier message: 17/04/2011, 09h46
  3. Ajouter des champs dans un formulaire.
    Par Invité dans le forum ASP.NET
    Réponses: 19
    Dernier message: 08/11/2007, 10h20
  4. Ajouter des champs dans un formulaire
    Par Luffy Duck dans le forum Général JavaScript
    Réponses: 1
    Dernier message: 18/05/2006, 10h30
  5. Ajouter des CHAMPS dans une table via ASP
    Par hysteresis dans le forum Access
    Réponses: 1
    Dernier message: 27/09/2005, 15h39

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo