0/5 (7 avis)
Vue 28 094 fois - Téléchargée 1 884 fois
function tab(col,lign) { this.tab = document.createElement("table"); this.autoid=1; for(j=0;j<lign;j++) { this.newRow = this.tab.insertRow(-1); for(i=0;i<col;i++) { this.newCell = this.newRow.insertCell(i); this.newCell.innerHTML = /* " "; */ this.autoid; this.newCell.setAttribute("id",this.autoid); with(this.newCell.style) { borderStyle = 'solid'; borderWidth = '2px'; borderColor = "#000000"; width = '100px'; height = '50px'; textAlign = 'center'; } this.autoid++; } } this.addtxt = function(id) { document.getElementById(id).innerHTML = "ne"; } document.body.appendChild(this.tab); }
27 juin 2009 à 23:04
function tab(col,lign)
{
this.tab = document.createElement("table");
this.autoid=1;
this.lign = 0;
this.largeur = 0;
this.newCell = null;
for(j=0;j
26 juin 2009 à 03:12
<head>
<style>
div#lecture {
border-style : solid;
border-width : 2px;
border-color : #000000;
width : 100px;
height :auto;
text-align : center;
}
</style>
</head>
<script language='javascript'>
function tab(col,lign,mep)
{
this.tab = document.createElement("table");
this.tab.setAttribute("align",mep);
this.autoid=1;
this.lign = lign;
for(j=0;j<lign;j++)
{
this.newRow = this.tab.insertRow(-1);
for(i=0;i<col;i++)
{
this.newCell = this.newRow.insertCell(i);
this.newCell.innerHTML = this.autoid;
this.newCell.setAttribute("id",this.autoid);
/* ############################# fonction de la cellule ################################### */
this.newCell.onclick = function () { window.alert(this.id); }
this.newCell.onmouseover function () { this.style.backgroundColor "#FFF000"; document.getElementById("lecture").innerHTML = " "+ parseFloat(this.innerHTML*6.55957).toFixed(2)+" Francs "; }
this.newCell.onmouseout function () { this.style.backgroundColor "#FFF"; }
/* ############################# style de l'objet ################################### */
with(this.newCell.style)
{
borderStyle = 'solid';
borderWidth = '2px';
borderColor = "#000000";
width = '100px';
height = '50px';
textAlign = 'center';
}
this.autoid++;
}
}
/* ############################# fonction de l'objet ################################### */
this.addtxt = function(id)
{
document.getElementById(id).innerHTML = "ne";
}
document.body.appendChild(this.tab);
}
var tab = new tab(10,10,"center");
</script>
</html>
produit customisé et dérivé pour ma grand-mère ...
26 juin 2009 à 00:59
<head>
</head>
<script language='javascript'>
function tab(col,lign,mep)
{
this.tab = document.createElement("table");
this.tab.setAttribute("align",mep);
this.autoid=1;
for(j=0;j<lign;j++)
{
this.newRow = this.tab.insertRow(-1);
for(i=0;i<col;i++)
{
this.newCell = this.newRow.insertCell(i);
this.newCell.innerHTML = /* " "; */ this.autoid;
this.newCell.setAttribute("id",this.autoid);
this.newCell.onclick = function () { window.alert(this.id); }
with(this.newCell.style)
{
borderStyle = 'solid';
borderWidth = '2px';
borderColor = "#000000";
width = '100px';
height = '50px';
textAlign = 'center';
}
this.autoid++;
}
}
this.addtxt = function(id)
{
document.getElementById(id).innerHTML = "ne";
}
document.body.appendChild(this.tab);
}
var tab = new tab(10,10,"center");
</script>
</html>
fonctionne sous firefox et sur IE
25 juin 2009 à 10:34
this.newCell.onclick = new Function("alert('test')");
25 juin 2009 à 10:27
this.newCell.onclick = "alert('test')";
s'affiche bien, mais il n'y a pas d'alert
j'ai essayé avec onClick, même résultat...
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.