Hi all,
I’m new in this forum, but i want to know if anyone could help me resolve this problem!
Um using DOM and javascript to create dinamically comboboxes. I also have a function associated with each comboboxe that runs when there is an update of the value. For each comboboxe onchange function it is passed a diferent value, but all the functions receive the same value!
HTML file:
[FONT=Courier New]<HTML>
<HEAD>
<script language=”JavaScript” type=”text/javascript” src=”bug.js”></script>
</HEAD>
<BODY onload=’bug(“tabelaID”);’>
<table ID=”tabelaID”>
<tbody>
</tbody>
</table>
</BODY>
</HTML>[/FONT]
bug.js:
[FONT=Courier New]function bug(id) {
var tabelaid = document.getElementById(id).getElementsByTagName(“TBODY”)[0];
for (var x=0; x < 3; x++) {
linha_principal = tabelaid.insertRow(x);
coluna_principal = document.createElement(“TD”);
tabela = document.createElement(“TABLE”);
tabela.id = “tabela_“+x;
tbody = document.createElement(“TBODY”);
linha1 = document.createElement(“TR”);
celula6 = document.createElement(“TD”);
valor7 = document.createElement(“A”);
valor7.innerHTML = x+”—–“;
celula6.appendChild(valor7);
valor6 = document.createElement(“SELECT”);
valor6.onchange = function () { alert(x); };
valor6.name = “berco
valor6.id = “berco_”+x;
valor6_1 = document.createElement(“OPTION”);
valor6_1.value = “0”;
valor6_1.innerHTML = “NÃO”;
valor6.appendChild(valor6_1);
valor6_2 = document.createElement(“OPTION”);
valor6_2.value = “1”;
valor6_2.innerHTML = “SIM”;
valor6.appendChild(valor6_2);
celula6.appendChild(valor6);
linha1.appendChild(celula6);
tbody.appendChild(linha1);
tabela.appendChild(tbody);
coluna_principal.appendChild(tabela);
linha_principal.appendChild(coluna_principal);
}
}[/FONT]
Can anyone help me?