I created a script that inserts some rows into a table. The script looks like this:
for (j = 0; j < <?php echo $i; ?>; j++)
{
if ((utilizator[j]['nume'].toLowerCase().indexOf(nume.toLowerCase()) != -1) && (utilizator[j]['locatie'].toLowerCase().indexOf(locatie.toLowerCase()) != -1) && (utilizator[j]['varsta'].toLowerCase().indexOf(varsta.toLowerCase()) != -1) && (utilizator[j]['email'].toLowerCase().indexOf(email.toLowerCase()) != -1) && (utilizator[j]['telefon'].toLowerCase().indexOf(telefon.toLowerCase()) != -1))
{
var insertString = '<td>'+utilizator[j]['nume']+'</td>';
insertString += '<td>'+utilizator[j]['locatie']+'</td>';
insertString += '<td>'+utilizator[j]['varsta']+'</td>';
insertString += '<td>'+utilizator[j]['email']+'</td>';
insertString += '<td>'+utilizator[j]['telefon']+'</td>';
insertString += '<td>'+utilizator[j]['punctaj']+'</td>';
if (utilizator[j]['suspendat'] != 1)
{
insertString += '<td id="suspendareButon'+utilizator[j]['id']+'"><input type="button" value="Suspenda" onclick="suspendare(1, '+utilizator[j]['id']+')" /></td>';
}
else
{
insertString += '<td id="suspendareButon'+utilizator[j]['id']+'"><input type="button" value="Activeaza" onclick="suspendare(0, '+utilizator[j]['id']+')" /></td>';
}
var trTag = document.createElement("tr");
trTag.innerHTML = insertString;
document.getElementById("utilizatoriId").appendChild(trTag);
}
}
The scripts runs fine in Firefox 4.0+ (so I didn’t see the problem) but one of my colleagues has Firefox 3.6.18 and it seems like the td tags are stripped. And I get something like <tr>data data data data...</tr> instead of <tr></td>data</td><td>data</td>...</tr>.
Any thoughts why this is happening?
Also in IE I get an error and nothing is displayed (the error is “object does not display this property or method”, I can’t exactly indicate the line because IE sucks at reporting…)
Can you try this?
You are not supposed to appendChild to a table, rather a tBody, but this will append to the table itself assuming I got all the syntax correct