解决方案 »

  1.   


    <style>
    .aaa{width:20;
    height:20
    }
    </style>
    <script language=javascript>
    function getIE(e){
     var t=e.offsetTop; 
    var l=e.offsetLeft;  
    var h=e.offsetHeight; 
    while(e=e.offsetParent) 

    t+=e.offsetTop; 
    l+=e.offsetLeft; 
    }
    t=parseInt(t)+parseInt(h)
    return(t+","+l); 
    }
    function show(obj)
    {
    document.getElementById("lastObj").value=obj.id
    var objColor=document.getElementById("divColor")
    objColor.style.display=""
    var positionColor=getIE(obj).split(",")
    objColor.style.top=positionColor[0]
    objColor.style.left=positionColor[1]

    }
    function getColor(obj)
    {
    document.getElementById("divColor").style.display="none"
    document.getElementById(document.getElementById("lastObj").value).style.backgroundColor=obj.style.backgroundColor
    }
    </script>
    <input id="aaa" name="aaa" onclick="show(this)">
    <input id="bbb" name="bbb" onclick="show(this)">
    <input id="ccc" name="ccc" onclick="show(this)">
    <input id="ddd" name="ddd" onclick="show(this)">
    <div id="divColor" style="display:none;position:absolute">
    <table border="1">
    <tr>
    <td class="aaa" style="background-color:red" onclick="getColor(this)">&nbsp;</td><td  class="aaa" style="background-color:blue" onclick="getColor(this)">&nbsp;</td><td  class="aaa"  style="background-color:green" onclick="getColor(this)">&nbsp;</td>
    </tr>
    <tr>
    <td class="aaa" style="background-color:pink" onclick="getColor(this)">&nbsp;</td><td  class="aaa" style="background-color:brown" onclick="getColor(this)">&nbsp;</td><td  class="aaa"  style="background-color:black" onclick="getColor(this)">&nbsp;</td>
    </tr>
    </table>
    <input type="hidden" name="lastObj">
    </div>