先存储原层的id,再按radio,返回的时候直接找存储的值

解决方案 »

  1.   

    请楼主测试一下,我这没问题了------------------------------------------------<?xml version="1.0" encoding="utf-8" ?> 
    <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <html> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    <title>放大镜 </title> 
    </head> <body> 
    <div id="main" style="visiblity: visible"> 
    <input id="text" type="text" size=32 value="" /> 
    <input type="button" value="click" onclick="show()" /> 
    </div> 

    <div id="data" style="position:absolute; border:1pt solid blue; padding:5px; z-index:100; left:50px; top:50px; display:none;"> 
    <!-- 相当于 
    border-top:1pt solid blue; 
    border-bottom:1pt solid blue; 
    border-left:1pt solid blue; 
    border-right:1pt solid blue; 
    --> 
    拖动此处移动层 
    <OBJECT ID="myData1" CLASSID="clsid:333C7BC4-460F-11D0-BC04-0080C7055A83" BORDER="0" WIDTH="0" HEIGHT="0"> 
    <PARAM NAME="DataURL" value="data2.txt"> 
    <PARAM NAME="UseHeader" VALUE="True"> 
    </OBJECT>  <form id="form1"> 
    <table id="outer_table" border=3 bordercolor="yellow" bgcolor="#green"> 
    <tr> 
    <td> 
    <table border=2 id="myTable1" DATASRC=#myData1 DATAPAGESIZE="5" bordercolor="blue"> 
    <thead> 
    <tr> 
    <td>&nbsp;</td>
    <td>公司名称 </td> 
    <td>联系人姓名 </td> 
    </tr> 
    </thead> 
    <tbody> 
    <tr height=25px valign="middle"> 
    <td width="70"> 
    <label> <input id="radio" type="radio" name="radio" /> </label> 
    <!-- input的check属性 checked="checked" --> 
    </td>  <td width="110"> 
    <div DATAFLD="公司名称"> 
    </td>  <td width="70"> 
    <div DATAFLD="联系人姓名"> 
    </td> 
    </tr>  </tbody> 
    </table> 
    <table align="center" border=2> 
    <tr> 
    <td align="center"> 
    <input id="first" type="button" value=" 第一页 " onclick="goFirstPage()"> 
    <input id="previous" type="button" value=" 上一页 " onclick="goPrePage()"> 
    <input id="next" type="button" value=" 下一页 " onclick="goNextPage()"> 
    <input id="last" type="button" value=" 最后一页 " onclick="goLastPage()"> 
    </td> 
    </tr> 

    <tr> 
    <td align="center"> 
    <input type="button" value=" 确认 " onclick="confirm()" /> 
    <input type="button" value=" 取消 " onclick="hide()" /> 
    </td> 
    </tr> 
    </table> 
    </td> 
    </tr> 
    </table>  
    </form> 
    </div> 

    <!-- 下面是js --> 
    <script language="JavaScript">  
    dataobj=document.getElementById("data"); 
    mainobj=document.getElementById("main"); 
    document.onmousedown=initializedrag; 
    document.onmouseup=new Function("dragapproved=false");  function initializedrag()

    if(event.srcElement.id=="data")

    offsetx=event.clientX; 
    offsety=event.clientY; 
    tempx=parseInt(dataobj.style.left);  
    tempy=parseInt(dataobj.style.top); 
    dataobj.style.cursor="hand"; 
    dragapproved=true; 
    document.onmousemove=drag_drop; 


      
    function drag_drop()

    if(dragapproved)

    dataobj.style.left=tempx+event.clientX-offsetx; 
    dataobj.style.top=tempy+event.clientY-offsety; 
    return false; 
    }  

        
    function show() 

    mainobj.style.display="none"; 
    mainobj.style.visibility="hidden"; 
    dataobj.style.display="block"; 
    dataobj.style.visibility="visible"; 
    }  function hide() 

    mainobj.style.visibility="visible"; 
    mainobj.style.display="block"; 
    dataobj.style.visibility="hidden"; 
    }  function goNextPage() 

    myTable1.nextPage(); 
    }  function goPrePage() 

    myTable1.previousPage(); 
    }  function goFirstPage() 

    myTable1.firstPage(); 
    }  function goLastPage() 

    myTable1.lastPage(); 
    }  function confirm() 
    {  
        var myTable = document.getElementById( "myTable1" ) ;
        for( var r=0; r < myTable.rows.length; r++ )        
        {
         var curRow = myTable.rows[r]     
         var arrRadios = curRow.getElementsByTagName( "INPUT" )
         for( var i=0; i< arrRadios.length; i++ )
         {
         if( arrRadios[i].type=="radio"&& arrRadios[i].checked )
         {
    var companyName = curRow.cells[1].firstChild.innerText;
    var contactName = curRow.cells[2].firstChild.innerText;

    document.getElementById( "text" ).value = companyName + "  --  " + contactName;
    hide();
    return;
         }
         }
        }
        alert("没有选中!");
    }   function save()


    </script> 
    </body> 
    </html>