Thomas Meinike: Radiobuttons mit JS dynamisch einfügen?

Beitrag lesen

Hallo,

Direkt auf das Attribut zugreifen mit:
document.getElementById("formular").childNodes[1].name = "auswahl";
bringt wieder nix.

Also eigentlich fällt mir nix mehr ein. Leider...

Vielleicht hilft dieser schon fast absurde Wuergaround mit dem "manuellen Hinzufuegen" von name="auswahl":

function CreateRadio(anzahl)
{
  for(i=0;i<anzahl;i++)
  {
    feld=document.createElement("input");
    feld.setAttribute("type","radio");
    feld.setAttribute("name","auswahl");
    document.getElementById("formular").appendChild(feld);
  }

if(document.documentElement.outerHTML)
  {
    temp1=document.getElementById("formular");
    for(i=0;i<temp1.childNodes.length;i++)
    {
      if(temp1.childNodes[i].type=="radio" && temp1.childNodes[i].name=="auswahl")
      {
        temp2=document.getElementById("formular").childNodes[i].outerHTML;
        document.getElementById("formular").childNodes[i].outerHTML=temp2.substring(0,temp2.length-1)+' name="auswahl">';
      }
    }
  }

MfG, Thomas