J'ai un layer dont le cellules peuvent évoluer en valeur et aussi sur le paramètre de la fonction qui est appelée.
- lorsque que je modifie les valeurs des cellules, il n'y a pas de problème, mais lorsque je modifie l'attribut onclick pour changer la valeur du paramètre à passer à la fonction (recup), alors les cellules ne click plus:
<html>
<head>
<style>
#csscontrole { HEIGHT: 105px; LEFT: 200px; BORDER: #000000 thin solid; POSITION: absolute; TOP: 20px; VISIBILITY: hidden; WIDTH: 20px; Z-INDEX: 1;}
</style>
<script language="JavaScript">
oTop=16;
oLeft=30;
var controle = new Controle();
function Controle() {
//alert("toto");
}
Controle.calculer = function() {
// fabrication du controle
html = "<DIV id=csscontrole style=\"HEIGHT: 1px; LEFT: 120px; TOP: 100px; WIDTH: 100px; VISIBILITY: hidden; \">";
html += "<table id='tidcontrole' cellspacing='0' cellpadding='0' border='0' width=60 valign='top'><tbody>";
html += "<tr><td";
html += " onclick='recup(\"A\");' align='center' style='cursor: hand;'> A </td>";
html += "<tr><td";
html += " onclick='recup(\"B\");' align='center' style='cursor: hand;'> B </td>";
html += "</td></tr>";
html += "<tr><td";
html += " onclick='recup(\"C\");' align='center' style='cursor: hand;'> C </td>";
html += "<tr><td";
html += " onclick='recup(\"D\");' align='center' style='cursor: hand;'> D </td>";
html += "</td></tr>";
html += "<tr><td width='100'>";
html += "</td></tr>";
html += "</tbody></table></div>";
document.write(html);
document.all.csscontrole.style.visibility='hidden';
}
Controle.maj = function() {
// racine est le noeud TBODY dont les lignes du tableau sont les childNodes
var racine = document.getElementById("tidcontrole").lastChild;
var iligne = 0;
var ligne = racine.childNodes[iligne];
var cell = ligne.firstChild;
// modification des cellules
cell = ligne.childNodes[0];
var ch_var_long = "recup(\"E\");";
cell.firstChild.nodeValue = "E";
//alert(cell.attributes["onclick"].nodeValue);
cell.removeAttribute("onclick");
//cell.attributes["onclick"].nodeValue = ch_var_long;
//cell.setAttribute("onClick", ch_var_long);
cell.onclick = ch_var_long;
//alert(cell.attributes["onclick"].nodeValue);
var iligne = 1;
var ligne = racine.childNodes[iligne];
var cell = ligne.firstChild;
cell = ligne.childNodes[0];
var ch_var_long = "recup(\"F\");";
cell.firstChild.nodeValue = "F";
//alert(cell.attributes["onclick"].nodeValue);
cell.removeAttribute("onclick");
//cell.attributes["onclick"].nodeValue = ch_var_long;
//cell.setAttribute("onClick", ch_var_long);
cell.onclick = ch_var_long;
//alert(cell.attributes["onclick"].nodeValue);
var iligne = 2;
var ligne = racine.childNodes[iligne];
var cell = ligne.firstChild;
cell = ligne.childNodes[0];
var ch_var_long = "recup(\"G\");";
cell.firstChild.nodeValue = "G";
//alert(cell.attributes["onclick"].nodeValue);
cell.removeAttribute("onclick");
//cell.attributes["onclick"].nodeValue = ch_var_long;
//cell.setAttribute("onClick", ch_var_long);
cell.onclick = ch_var_long;
//alert(cell.attributes["onclick"].nodeValue);
var iligne = 3;
var ligne = racine.childNodes[iligne];
var cell = ligne.firstChild;
cell = ligne.childNodes[0];
var ch_var_long = "recup(\"H\");";
cell.firstChild.nodeValue = "H";
//alert(cell.attributes["onclick"].nodeValue);
cell.removeAttribute("onclick");
//cell.attributes["onclick"].nodeValue = ch_var_long;
//cell.setAttribute("onClick", ch_var_long);
cell.onclick = ch_var_long;
//alert(cell.attributes["onclick"].nodeValue);
}
function valid(nTop,nLeft,nHaut,nLarg)
{
//alert(document.all.controle.style.visibility);
var nTop=eval(nTop + nHaut + oTop + document.all.tdcontrole.offsetTop);
var nLeft=eval(nLeft + oLeft + document.all.tdcontrole.offsetLeft - document.all.tdcontrole.offsetWidth + nLarg);
document.all.csscontrole.style.pixelTop=nTop;
document.all.csscontrole.style.pixelLeft=nLeft;
document.all.csscontrole.style.visibility='visible';
}
function recup(MaValeur)
{
document.form1.idcontrole.value=MaValeur;
Controle.maj();
document.all.csscontrole.style.visibility='hidden';
}
</script>
</head>
<body>
<script language="JavaScript">
Controle.calculer();</script>
<table width="250" class="table1">
<form method="POST" name="form1" action="/Asp/test/Test.asp">
<tr><td width="50%">Ouvir le contrôle</td>
<td width="50%" id=tdcontrole>
<INPUT type="text" name="idcontrole" id="idcontrole" class="zone" size="10" border="0"><A OnClick="javascript:valid(this.offsetTop,this.offsetLeft,this.offsetHeight,this.offsetWidth);"><IMG src="/_gfi_copy/img/BoutonOuvrir.gif" border="0" width="16"></a>
</td></tr></form></table>
</body>
</html>
Merci pour votre aide