房天下 > 房天下问答 > 家居装修 > 装修前
  • 如何用JavaScript实现对radio button的控制实现对窗体打开关闭的功能?

    有两个radio 一个yes一个no,选yes的时候打开窗体,选no的时候关闭窗体,我用的是onclick事件现在的问题是我点击yes或者no都可以实现窗体的打开,但再次点击也可以关闭,请问怎么解决???谢谢

    门窗 开关 举报

    提问者:学以用

    发布于2011-01-25

相关搜索推荐

共1个回答
  • 恒好进出口 丨Lv 0
    <html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><script language="javascript">function controlWindow(){ var myRadios=document.getElementsByName("myRadio"); if(myRadios[0].checked==true) window.open(); else window.close();}</script></head><body> <input type="radio" name="myRadio" value="1" onclick="controlWindow()"/>yes <input type="radio" name="myRadio" value="2" onclick="controlWindow()"/>no</body></html>
    +1 2011-01-25 举报
免责声明:问答内容均来源于互联网用户,房天下对其内容不负责任,如有版权或其他问题可以联系房天下进行删除。