使用单选按钮中的 value 属性
- <html>
- <head>
- <script type="text/javascript">
- function check(browser)
- {
- document.getElementById("answer").value=browser
- }
- </script>
- </head>
- <body>
-
- <p>您喜欢哪款浏览器?</p>
-
- <form>
- <input type="radio" name="browser" onclick="check(this.value)" value="Internet Explorer">Internet Explorer<br />
- <input type="radio" name="browser" onclick="check(this.value)" value="Firefox">Firefox<br />
- <input type="radio" name="browser" onclick="check(this.value)" value="Netscape">Netscape<br />
- <input type="radio" name="browser" onclick="check(this.value)" value="Opera">Opera<br />
- <br />
- 您喜欢的浏览器是:<input type="text" id="answer" size="20">
- </form>
-
- </body>
- </html>