NetizenKane: Dynamische Button-Events mit korrektem Bezug

Beitrag lesen

Hallo Gernot,

ich habe jetzt mal deinen Rat befolgt und das "fremde" Colorpicker-Skript (das bei näherer Betrachtung wirklich hanebüchen ist) ersetzt durch ein einfaches Testskript. Blöderweise bleibt der Effekt der gleiche:

http://www.clancodes.de/test3.html

Code:
######################################################################
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">

<script type="text/javascript">
<!--
var rowcount = 1;

function new_field()
{
 var row = document.getElementById('form_table').insertRow(rowcount);
 var cell_1 = row.insertCell(0);
 var cell_2 = row.insertCell(1);

var text = document.createTextNode('Option ' + (rowcount + 1) + ' ');
 cell_1.appendChild(text);

var input = document.createElement('input');
 input.type = 'text';
 input.name = 'option[]';
 input.size = 60;
 input.maxlength = 150;
 cell_1.appendChild(input);

var text = document.createTextNode('Color ');
 cell_2.appendChild(text);

var input = document.createElement('input');
 input.type = 'text';
 input.name = 'color[]';
 input.id = 'color_' + rowcount + '';
 input.size = 10;
 input.maxlength = 7;
 cell_2.appendChild(input);

var input = document.createElement('input');
 var pickColor_string = "pickColor('color_' + (rowcount-1) +'', 'colorwatch_' + (rowcount-1) +'');";
 var pickColor = new Function(pickColor_string);
 input.type = 'button';
 input.name = 'pick[]';
 input.value = 'Pick';
 input.rowcount = rowcount-1;
 input.onclick = function () { setColor('color_' + (rowcount-1) + ''); }
 cell_2.appendChild(input);

rowcount++;
}

function setColor(id)
{
 document.getElementById(id).value = "Farbe";
}
//-->
</script>

</head>
<body>

<form name="posting" action="save.php" method="post">
 <table id="form_table" border="1" cellspacing="0" cellpadding="0">
    <tr>
     <td>Option 1 <input name="option[]" id="option_0" type="text" size="60" maxlength="150" /></td>
     <td>Color <input size="10" maxlength="7" name="color[]" id="color_0" /><input type="button" name="pick[]" onclick="setColor('color_0');" value="Pick" /></td>
    </tr>
  <tr>
   <td colspan="3"><input type="button" onclick="new_field();" value="Add Row" /></td>
  </tr>
 </table>
</form>

</body>
</html>

Hast du oder sonst jemand vielleicht noch eine Idee?
Gruss
Kane