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
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Test edit td</title>
<script type="text/javascript">
function ajout(td, id_ligne){
if(td.getAttribute("clicked")==1)return
td.setAttribute("clicked", "1");
tmp = td.firstChild.nodeValue;
td.removeChild(td.firstChild);
divform = document.createElement("form");
divform.setAttribute("action", "taPagePHP.php");
divform.setAttribute("method", "post");
formSubmit = document.createElement("input");
formSubmit.setAttribute("type","submit");
formSubmit.setAttribute("value","Enregistrer");
formCancel = document.createElement("input");
formCancel.setAttribute("type","button");
formCancel.setAttribute("value","Annuler");
formHidden = document.createElement("input");
formHidden.setAttribute("type","hidden");
formHidden.setAttribute("value",id_ligne);
formCancel.onclick = function(){
td.innerHTML = tmp;
td.setAttribute("clicked", "0");
}
divtexte = document.createElement("textarea");
divform.appendChild(divtexte);
divform.appendChild(formSubmit);
divform.appendChild(formCancel);
divform.appendChild(formHidden);
td.appendChild(divform);
divtexte.innerHTML = tmp;
}
</script>
<style type="text/css">
textarea{
width:200px;
height:50px;
font-family:arial;
font-size:11px;}
</style>
</head>
<body>
<table>
<tr>
<td onclick="ajout(this, 1);">
Ceci est un test.
</td>
</tr>
<tr>
<td onclick="ajout(this, 2);">
Ceci est un autre test.
</td>
</tr>
<tr>
<td onclick="ajout(this, 3);">
Ceci est encore un autre test.
</td>
</tr>
</table>
</body>
</html> |
Partager