JavaScript 参考手册
Radio value 属性
显示选定的单选按钮
源代码:
点击运行 »
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>蜜蜂教程(mifengjc.com)</title> <script> function displayResult(browser) { document.getElementById("result").value = browser } </script> </head> <body> <p>选择你最喜欢的浏览器:</p> <form> <input type="radio" name="browser" onclick="displayResult(this.value)" value="Internet Explorer">Internet Explorer<br> <input type="radio" name="browser" onclick="displayResult(this.value)" value="Firefox">Firefox<br> <input type="radio" name="browser" onclick="displayResult(this.value)" value="Opera">Opera<br> <input type="radio" name="browser" onclick="displayResult(this.value)" value="Google Chrome">Google Chrome<br> <input type="radio" name="browser" onclick="displayResult(this.value)" value="Safari">Safari<br><br> 你最喜欢的浏览器是: <input type="text" id="result"> </form> </body> </html>
运行结果:
点击运行 »