création de champs automatique
Bonjour à tous , j'ai un petit soucis dans mon formulaire. Voila je veux créer un formulaire avec plusieurs options qui affiche dans le même formulaire de nouveaux champs selon le choix désiré plus haut dans le formulaire. Après quelque recherches sur le net j'ai réussi a créer mon automatisation, mais mon soucis réside dans le fait qu'il se place en bas de mon formulaire alors que je le désire en dessous de mes choix demandés.
Voici mon code java script dans mon head :
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
|
<script type="text/javascript">
var inputtext;
var inputlabel;
function
function InputText(text){
var sortie = document.getElementById("form"); // attribut id de a balise html
inputtext = document.createElement("input"); // creation d'une textbox
inputtext.name="textbox";
inputtext.id="textbox";
inputtext.type="text";
inputlabel = document.createElement("label"); //creation du label du de la text box
inputlabel.innerHTML=text;
inputlabel.appendChild(inputtext);
sortie.appendChild(inputlabel);
}
function clickoption(id){
if(inputlabel && inputtext){
inputlabel.innerHTML=id;
inputtext = document.createElement("input"); // creation d'une textbox
inputtext.name="textbox";
inputtext.id="textbox";
inputtext.type="text";
inputlabel.appendChild(inputtext);
}else{
InputText(id);
}
}
</script> |
et voici mon code de mon formulaire dans la balise body :
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 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
|
<form id="form" vname="FormName" action="formulaires/PHPFormmail.php" method="post" enctype="multipart/form-data" name="form">
<div align="center">
<table border="0" cellpadding="5" cellspacing="0" width="552">
<tr>
<td width="132">Mail expéditeur :</td>
<td width="400"><input name="email" type="text" size="35" /></td>
</tr>
<tr>
<td><span class="Style2">Destinataire</span></td>
<td><input name="destinataire" type="hidden" id="destinataire" value="<?php echo $to ?>" /></td>
</tr>
<tr>
<td>Sujet :</td>
<td><input name="subject" type="text" value="Sugestion d'idée(s)" size="35"></td>
</tr>
<tr>
<td>Demandeur :</td>
<td><input name="demandeur" type="text" size="35" id="demandeur"></td>
</tr>
<tr>
<td>Association : </td>
<td><input name="association" type="text" size="35" id="association"></td>
</tr>
<tr>
<td>Réponse souhaitée :</td>
<td>
<label><input type="radio" id="mail : " name="opt" onclick="clickoption(this.id);" />mail</label>
<label><input type="radio" id="adresse : " name="opt" onclick="clickoption(this.id);" />courrier</label>
<label><input type="radio" id="telephone : " name="opt" onclick="clickoption(this.id);" />telephone</label>
<p> </p>
<p><br/>
</br>
</br>
</br>
</p>
<td>
</tr>
<tr>
<td>Message :</td>
<td><textarea rows="12" name="msg" cols="60">
</textarea></td>
</tr>
<tr>
<td>Fichier joint :</td>
<td><input type="hidden" name="MAX_FILE_SIZE" value="100000"><input name="NomFichier" type="file" size="16">
*</td>
</tr>
<tr>
<td><span class="Style2">Priorité:</span></td>
<td>
<div align="left">
<input type="submit" value="Envoyer"></div> </td>
</tr>
</table>
</div>
<p align="center">* : Fichiers acceptés : .pdf, .doc, .xls, .jpg, .bitmap<br>
1 seul fichier par envoi.</p>
<div align="center">
<input name="saisie" type="hidden" id="saisie" value="1" />
</div>
</form> |
si quelqu'un à une idée, pour réaliser cette action, ça serai cool, je suis un peu largué en java.