ik heb een probleem bij het dynamisch aanmaken van velden. Hij post nooit de waarden van de domobjecten in Firefox. In IE doet hij dit perfect hoe komt dit?

    function addRowToTable()
{
  var tbl = document.getElementById('tblSample');
  var lastRow = tbl.rows.length;
  // if there's no header row in the table, then iteration = lastRow + 1
  var iteration = lastRow;
  var row = tbl.insertRow(lastRow);
  
  // left cell
  var cellLeft = row.insertCell(0);
  var textNode = document.createTextNode(iteration);
  
  // right cell
  var cellRight = row.insertCell(1);
  var el = document.createElement('input');
  el.type = 'text';
  el.name = 'txtrow' + iteration;
  el.id = 'txtrow' + iteration;
  el.size = 40;
  cellRight.appendChild(el);

}
Ik heb dit even die functie in een pagina ingewerkt.
<?php
echo '
<html>
<head>
<style>.klik{cursor: pointer}</style>
<script>
function addRowToTable()
{
var tbl = document.getElementById("tblSample");
var lastRow = tbl.rows.length;
// if there"s no header row in the table, then iteration = lastRow + 1
var iteration = lastRow;
var row = tbl.insertRow(lastRow);
// left cell
var cellLeft = row.insertCell(0);
var textNode = document.createTextNode(iteration);
// right cell
var cellRight = row.insertCell(1);
var el = document.createElement("input");
el.type = "text";
el.name = "txtrow" + iteration;
el.id = "txtrow" + iteration;
el.size = 40;
cellRight.appendChild(el);
}
</script>
</head>
<body>
<div class="klik" onClick="addRowToTable();">klik om rij toe te voegen</div>
<table id="tblSample"><tr><td>test veld 1</td><td>test veld 2</td></tr></table>
</body>
</html>';
?>

Bij mij doet dat precies het zelfde in alle browsers.
Wat is precies het probleem?
je hebt er ook nog input velden in staan? Die heten waarschijnlijk allemaal hetzelfde?
fout zat hem dat ik de form binnen een table begon!

Reageren