t0bias: Javascript input feld mit onclick event

Beitrag lesen

Hallo,

Ich hab folgendes Problem:

Wenn ich mit Javascript eine Tabelle erstelle, die einen Radio Button enthaelt der Radio Button hat das event onclick. onclick ruft eine Javascript Methode auf. Allerdings wird bei dem anklicken des Radio Buttons nie eine Javascript Methode aufgerufen.

Es funktioniert mit Mozilla Firefox, allerdings nicht mit dem Internet Explorer. Wenn ich den erzeugten HTML code jedoch in eine andere HTML Datei kopiere und diese mit dem IE oeffne funktioniert es.

Der Javascript Code sieht wie folgt aus:

function getTable()
{
        var x = xmlDoc.getElementsByTagName("item");
 var table = document.createElement("table");
 table.setAttribute("id", "table");
 table.setAttribute("cellPadding",5);
 var tmp = document.createElement("tbody");

table.appendChild(tmp);
 var row = document.createElement('tr');
 var container = document.createElement("th");
 row.appendChild(container);
 for (j=0;j<x[0].childNodes.length;j++)
 {
  if (x[0].childNodes[j].nodeType != 1) continue;
  var container = document.createElement("th");
  var theData = document.createTextNode(x[0].childNodes[j].nodeName);
  container.appendChild(theData);
  row.appendChild(container);
 }
 tmp.appendChild(row);

for (i=0;i<x.length;i++)
 {
  var row = document.createElement("tr");
  row.setAttribute("id", i);
  if(i%2 == 0) row.setAttribute("bgcolor", "#808080");
  var select = document.createElement("td");
  var button = document.createElement("input");
  button.setAttribute("type", "radio");
  button.setAttribute("onclick","displayDetail("+i+")");
  select.appendChild(button);
  row.appendChild(select);

for (j=0;j<x[i].childNodes.length;j++)
  {
   if (x[i].childNodes[j].nodeType != 1) continue;
   var container = document.createElement("td");

var theData = document.createTextNode(x[i].childNodes[j].firstChild.nodeValue);
   if(j==1){
    var link = document.createElement("a");
        link.setAttribute("href", theData);
    link.setAttribute("target", "_blank");
    link.appendChild(theData);
    theData = link;
   }
   container.appendChild(theData);
   row.appendChild(container);
  }
  tmp.appendChild(row);
 }
 table.appendChild(tmp);
 document.getElementById("writeroot").replaceChild(table, document.getElementById("writeroot").firstChild);
}

Der erzeugte HTML code sieht wie folgt aus:

<DIV id=writeroot>
<TABLE id=table cellPadding=5>
<TBODY>
<TR>
<TH></TH>
<TH>title</TH>
<TH>link</TH>
<TH>description</TH></TR>

<TR id=0 bgcolor="#808080"> <TD><INPUT onclick=displayDetail(0) type=radio></TD> <TD>Putting RDF to Work</TD> <TD><A href="http://www.google.de" target=_blank>http://xml.com/pub/2000/08/09/rdfdb/index.html</A></TD> <TD>Tool and API support for the Resource Description Frameworkis slowly coming of age. Edd Dumbill takes a look at RDFDB,one of the most exciting new RDF toolkits.</TD>
</TBODY>
</TABLE>
</DIV>

Hat jemand eine Idee woran es liegen koennte?

Gruss,
Tobias