<body>
  <html:form action="/table">
  <table width="111" height="150" border="1">
<c:forEach items="${item}" var="mj" varStatus="i">
         <c:if test="${(i.count - 1) % 4 == 0}">
           <tr>
         </c:if>
           <td>
              <table border="1">
                 <tr>
                  <td height="120"><img src="${mj.statu=='空闲'?'img/png-0638.png':'img/png-0629.png'}" onclick="popUp(this.value)" ></td>                 
                 </tr>
                 <tr>
                    <td><a>${mj.tableId}</a></td>
                 </tr>
              </table>
           </td>
         <c:if test="${i.count % 4 == 0}">
         </c:if>
    </c:forEach> 
  </table>
  <table id="itemopen" class="box" style="display:none">
<tr>
<td>弹出菜单</td>
</tr>
<tr>
<td><a href="../../../index.html" onclick="alert(this.value)">本站首页</a></td>
</tr>
<tr>
<td><a href="../../navigation/newscript.htm" class="cc"  onclick="alert(this.value)">最新更新</a></td>
</tr>
<tr>
<td><a href="" class="cc" onclick="alert(this.value)">梦想软件</a></td>
</tr>
<tr>
<td><a href="../../../jsschool/index.htm" class="cc" onclick="alert(this.value)">>桌面壁纸</a></td>
</tr>
<tr>
<td><a href="popmenu.htm" class="cc" onclick="alert(this.value)">>更多连接</a></td>
</tr>
<tr>
<td><a href="popmenu.htm" class="cc" onclick="alert(this.value)">>更多连接</a></td>
</tr>
<tr>
<td ><a href="popmenu.htm" class="cc">更多连接</a></td>
</tr>
</table>
<!-- End of Popup Menu -->
  <script language="JavaScript">

function popUp(v) {
alert(v);
newX = window.event.x + document.body.scrollLeft
newY = window.event.y + document.body.scrollTop
menu = document.all.itemopen
if ( menu.style.display == ""){
menu.style.display = "none" }
else {
menu.style.display = ""}
menu.style.pixelLeft = newX - 50
menu.style.pixelTop = newY - 50
}
</script> 
 </html:form>
  </body>
通过点击图片 显示菜单选项,现在我希望在点击菜单的时候获取对应点击图片所包含的Id , 并且弹出显示即可。希望哪位大哥知道的 给点办法啊。

解决方案 »

  1.   

    function popUp(obj){
    alert(obj.id);
    }
    <td height="120"><img id="img1" src="" onclick="popUp(this)" > </td> 
      

  2.   

    既然你是点击图片后才显示菜单,可以这样考虑
    点击图片的时候在脚本中就直接获得该图片的id,然后在点菜单是直接调用就可以了
    ...
    <td height="120"> <img src="${mj.statu=='空闲'?'img/png-0638.png':'img/png-0629.png'}" onclick="popUp(this)" > </td>
    ...
    var picid;
    function popUp(o) {
        //在脚本中添加代码
        picid = o.id;
    }
    然后每个弹出菜单的onclick事件也要做修改
    ...
    <td> <a href="../../../index.html" onclick="showPicId()">本站首页 </a> </td>
    ...
    function showPicId(){
        alert("picid:\t" + picid);
    }
      

  3.   

    function popUp(obj){ 
    alert(obj.id); 

    <td height="120"> <img id="img1" src="" onclick="popUp(this)" > </td>