我现在有一个复选框
<input type="checkbox" name="check" value="xx">显示数据点两幅图片
<img src="<%= graphURL %>" border=0 usemap="#<%= filename %>">

<img src="<%= graphURL1 %>" border=0 usemap="#<%= filename1 %>">要实现,钩上复选框后,显示其中一个,不勾上显示另外一个,要怎么做啊?谢谢

解决方案 »

  1.   

    <html>
    <head><script language=javascript>function a(o){
    if(o.checked){
    document.getElementById("a").style.display="";
    document.getElementById("b").style.display="none";
    }else{
    document.getElementById("b").style.display="";
    document.getElementById("a").style.display="none";
    }
    }</script>
    </head>
    <body >
    <input type="checkbox" name="ck" onclick="a(this);">
    <div id=a style="display:none">a</div>
    <div id=b style="display:none">b</div>
    </body>
    </html>
      

  2.   

    首先谢谢楼上的,其中的id=a,id=b 赋值给两副图片id是吗
      

  3.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html>
    <head>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>新建网页</title>
    <style type="text/css">
    body{}
    </style>
    </head>
    <body>
    <input type="checkbox" onclick="f(this);" id="c1"><p>
    <img src="http://www.google.cn/intl/zh-CN/images/logo_cn.gif" id="img1"> 
    <img src="http://www.baidu.com/img/logo.gif" id="img2">
    <script language="javascript">
    var c1 = document.getElementById("c1");
    function f(){
    if (c1.checked){
    document.getElementById("img1").style.display = "none";
    document.getElementById("img2").style.display = "inline";
    }else{
    document.getElementById("img1").style.display = "inline";
    document.getElementById("img2").style.display = "none";
    }
    }
    f(c1);
    </script>
    </body>
    </html>