Bonjour, nouvelle évolution, à présent j'ai un bouton qui ouvre bien des lignes, et je reçois le mail correctement.
en revanche, j'ai toujours mes deux lignes désignation qui sont remplies identiquement. je suppose qu'il faut ajouter une variable, mais je ne sai spas du tout laquelle. je refournis les codes
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta name="generator" content="HTML Tidy for Windows (vers 14 February 2006), see
www.w3.org">
<title></title>
</head>
<body>
<form method="post" action="mail.php">
<input type="hidden" name="subject" value="Commande"/>
<table>
<tbody>
<tr>
<td>Votre société</td>
<td width="180">
<input type="text" name="Societe" size="30" />
</td>
</tr>
<tr>
<td>Votre Email</td>
<td>
<input type="text" name="Email" size="30" />
</td>
</tr>
<tr>
<td>Objet</td>
<td>
<input type="text" name="Sujet" size="30" />
</td>
</tr>
<tr>
<td>Informations complémentaires</td>
<td>
<p>
<textarea name="Informations" cols="30" rows="3"></textarea>
</p>
</td>
</tr>
</tbody>
</table>
<table id="articles">
<tbody>
<tr>
<th width="91"><div align="left">Référence</div></th>
<th width="218"><div align="left">Désignation</div></th>
<th width="66"><div align="left">Quantité</div></th>
</tr>
</tbody>
</table>
<table width="390" border="0">
<tr>
<td width="178"><div align="right">
<input type="button" onclick="addLigne('articles');" value="Ajouter un article" />
</div></td>
<td width="196"><input type="submit" value="Envoyer" /></td>
</tr>
</table>
</form>
<script type="text/javascript">
/*
retourne une liste des nodes correspondantes
fonctions applicables sur la sortie :
snapshotLength : retourne le nombre d'elements
snapshotItem(i): retourne l'element i
*/
function getByAt(parent, balise, attribut, valeur) {
if (valeur!="") {
return document.evaluate(
"//"+balise+"[@"+attribut+"=\""+valeur+"\"]",
parent,
null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
null);
}else{
return document.evaluate(
"//"+balise+"[@"+attribut+"]",
parent,
null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
null);
}
}
function makeXHR(){
var xmlHttp;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("Your browser does not support AJAX!");
return false;
}
}
}
return xmlHttp;
}
function maFonctionAjax(obj){
var xhr = makeXHR();
var input_nom = getByAt(obj.parentNode.parentNode, "input", "name", "Nom[]");
//LANCE LE FICHIER PHP AVEC LA VALEUR DU CHAMP ref
xhr.open('GET',"maPageDeRequPHP.php?id="+encodeURIComponent(obj.value), true);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status==200){
if (document.getElementById){
//AFFICHE LA REPONSE DANS LE CHAMP nom
for (var i=0; i<input_nom.snapshotLength; i++){
input_nom.snapshotItem(i).value = xhr.responseText;
}
}
}
}
//xhr.setRequestHeader('Content-type','application/x-www-form-urlencoded');
xhr.send(null);
return null;
}
function addLigne(table) {
var parent = document.getElementById(table);
if (parent.getElementsByTagName("tbody"))
parent = parent.getElementsByTagName("tbody")[0];
var new_tr = document.createElement("tr");
var td1 = document.createElement("td");
var td2 = document.createElement("td");
var td3 = document.createElement("td");
var td4 = document.createElement("td");
td1.innerHTML = '<input type="text" name="Ref[]" value="" size="6" onchange="return maFonctionAjax(this);" />';
td2.innerHTML = '<input type="text" name="Nom[]" value="" size="30" />';
td3.innerHTML = '<input type="text" name="Quantite[]" value="" size="6" onchange="checkQuantity(this);" />';
td4.innerHTML = '<input type="button" onclick="this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);" value="Enlever" />';
new_tr.appendChild(td1);
new_tr.appendChild(td2);
new_tr.appendChild(td3);
new_tr.appendChild(td4);
parent.appendChild(new_tr);
}
</script>
</body>
</html>
<?php
$to = "";
$from = "From: " . $_POST['Email'];
$subject = $_POST['subject'];
$message="";
if(isset($_POST['subject'])){
$message.=" Societe: ".$_POST['Societe']."\n";
$message.=" Email: ".$_POST['Email']."\n";
$message.=" Objet: ".$_POST['Sujet']."\n";
$message.="Information complementaire: ".$_POST['Informations']."\n";
foreach($_POST['Ref'] as $key => $value){
$message .=" Ref :".$_POST['Ref'][$key]." quantite ".$_POST['Quantite'][$key]." Nom ".$_POST['Nom'][$key]."\n";
}
mail($to, $subject, $message, $from);
header("Location: l");
}
?>