Thread HTML/Javascript
(7 answers)
Opened by radio at 2010-09-17 11:07
Das Beispiel mal sauberer und funktionierend:
Code (html): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Foo</title> <script type="text/javascript">//<![CDATA[ function selectedSex() { var options = document.forms["foo"].elements["sex"]; for (var i = 0; i < options.length; i++) { var sex = options[i]; if (sex.checked) return sex.value; } return "neutral"; } function next(text) { var popup = window.open(); popup.document.write("<div>" + text + "</div>"); } //]]></script> </head> <body> <form id="foo" action="about:blank"><div> <input type="radio" id="sex-male" name="sex" value="male" /> <label for="sex-male">Male</label><br /> <input type="radio" id="sex-female" name="sex" value="female" /> <label for="sex-female">Female</label><br /> <input type="button" value="weiter" onclick="next(selectedSex())" /> </div></form> </body> </html> (edit: HTML-Dokument entsprechend Standard korrigiert) Last edited: 2010-09-17 18:54:03 +0200 (CEST) When C++ is your hammer, every problem looks like your thumb.
|