Wie kann ich auf ein mit document.write(
Sebastian
- javascript
0 Carsten
Hallo,
ich habe mit nachfolgendem Sourcecode ein Radio-Button in einer HTML-Datei erzeugt.
document.write("<input type=radio name='appointment' value='" + termin[i] + "'>" + termin[i] + "<br>");
Wenn ich nun mit unten stehendem Befehl auf das Objekt zugreifen will, wird das Objekt nicht gefunden. Warum? Wie kann ich das Problem lösen?
if(document.proposal.appointment[0].checked == true)
{
hashstring += document.proposal.appointment[0].value + ";";
}
else if(document.proposal.appointment[1].checked == true)
{
hashstring += document.proposal.appointment[1].value + ";";
}
Schon im Voraus vielen Dank für Eure Hilfe!
Gruß,
Sebastian
Hallo Sebastian,
Folgendes Script funktioniert bei mir einwandfrei:
<script>
termin=new Array("1.1.2001","2.2.2002");
function test()
{
hashstring="";
if(document.proposal.appointment[0].checked == true)
hashstring += document.proposal.appointment[0].value + ";";
else if(document.proposal.appointment[1].checked == true)
hashstring += document.proposal.appointment[1].value + ";";
alert (hashstring);
}
</script>
<body>
<form name="proposal">
<script>
document.write('<input type=radio name="appointment" value="' + termin[0] + '" checked>' + termin[0] + '<br>');
document.write('<input type=radio name="appointment" value="' + termin[1] + '">' + termin[1] + '<br>');
</script>
<input type=button onClick="test();" value="Los">
</form>
Anmerkungen:
Gruss,
Carsten