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
|
<html>
<head>
<title></title>
<script language="">
id = 0;
function insAdresses (site, nomcontact, prenomcontact, lib, cp, ville, pays, telcontact, portcontact, faxcontact, mailcontact)
{
// ajout de TR
maLigne = document.createElement("tr");
maLigne.id = id
if (window.attachEvent) {
maLigne.onmouseenter = function() {this.style.backgroundColor = "lime";};
maLigne.onmouseleave = function() {this.style.backgroundColor = "";};
maLigne.onclick = function(){voir_nb_adresse(this.id)};
document.getElementById('tabadresses').lastChild.appendChild(maLigne);
}
else if (window.addEventListener) {
maLigne.addEventListener("mouseover", function() {this.style.backgroundColor = "lime"}, false);
maLigne.addEventListener("mouseout", function() {this.style.backgroundColor = ""}, false);
maLigne.addEventListener("click", function(){voir_nb_adresse(this.id)}, false);
document.getElementById('tabadresses').appendChild(maLigne);
}
// ajout du 1er TD
macell1 = document.createElement("td");
macell1.id = "1_" + id;
macell1.className = "col3";
document.getElementById(id).appendChild(macell1);
// ajout 1er input hidden
moninput1 = document.createElement("input");
moninput1.type = "hidden";
moninput1.id = "adresse_" + id;
moninput1.name = "adresse[]";
moninput1.size = 2;
moninput1.value = id;
document.getElementById(macell1.id).appendChild(moninput1);
// ajout 2eme input hidden
moninput2 = document.createElement("input");
moninput2.type = "hidden";
moninput2.name = "site[]";
moninput2.size = 2;
moninput2.value = site;
document.getElementById(macell1.id).appendChild(moninput2);
// ajout du texte dans la cellule (TextNode)
montext1 = document.createTextNode(site);
document.getElementById(macell1.id).appendChild(montext1);
// ajout du 2eme TD
macell2 = document.createElement("td");
macell2.id = "2_" + id;
macell2.className = "col3";
document.getElementById(id).appendChild(macell2);
// ajout input hidden
moninput22 = document.createElement("input");
moninput22.type = "hidden";
moninput22.name = "moncontact[]";
moninput22.size = 2;
moninput22.value = nomcontact;
document.getElementById(macell2.id).appendChild(moninput22);
// ajout du texte dans la cellule (TextNode)
montext2 = document.createTextNode(nomcontact);
document.getElementById(macell2.id).appendChild(montext2);
id++;
}
function voir_nb_adresse(num_id) {
alert("id du tr = " + num_id + " et contenu de INPUT adresse_" + num_id + " => " + document.getElementById("adresse_" + num_id).value);
}
</script>
</head>
<body >
<input type="button" name="ajout_data" value="ajout data" onclick="insAdresses('site', 'nomcontact', 'prenomcontact', 'lib', 'cp', 'ville', 'pays', 'telcontact', 'portcontact', 'faxcontact', 'mailcontact')"/>
<table id="tabadresses" border="1"></table>
</body>
</html> |
Partager