Effacement champs lors d'ajout d'autre
Bonjour,
Pour une publication, je peux avoir un ou plusieurs auteur/editeur.
Donc dans le formulaire j'ai créer un bouton "+" pour pouvoir ajouter autant qu'il en faut.
Tout fonctionne bien mais y a un hic.
A chaque fois que le clique sur le bouton "+" pour ajouter un auteur, cela efface nom/prenom etc des autres auteurs déjà rempli ce qui est très gênant.
Pourquoi cela ?
Y a-t-il une parade et eviter cela ?
Code coté HTML :
Code:
1 2 3 4
| <div id="addInput_auteur" class="addInput_auteur"></div>
<label for="add_Author" class="label_aut+">
<input type="button" name="+" value="+" id="add_Author" class="btn_add" onclick="add_auteur();">
</label> |
Code coté JS
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| function add_auteur(){
var input = addInput_auteur.innerHTML;
//addInput.innerHTML = input + '<input type="text" name="ch_toto[]" />\n';
var text = '<label class="label_type_c">Type contribute:<abbr class="required" title="required">*</abbr>:';
text += '<SELECT name="ch_type_contr[]" id="ch_type_contr" size="1">';
text += '<option value="" >select</option>';
text += '<option value="author">author</option>';
text += '<option value="editor">editor</option>';
text += '<option value="both">both</option></select></label>';
text += '<label class="label_autN"> first name:<abbr class="required" title="required">*</abbr>:';
text += '<input type="text" name="ch_auteur_fn[]" id="ch_auteur_fn" maxlength="45"></label>';
text += '<label class="label_midN">mid. name:';
text += '<input type="text" name="ch_auteur_mn[]" id="ch_auteur_mn" maxlength="8"></label><br/>';
text += '<label class="label_lastN">last name:<abbr class="required" title="required">*</abbr>:';
text += '<input type="text" name="ch_auteur_ln[]" id="ch_auteur_ln" maxlength="45"></label>';
addInput_auteur.innerHTML = input + text + '\n<br>';
} |
Merci de votre aide