有一个文本框(ID="name"),后面有一个按钮,点击这个按钮,谈出一个框(用JS做的)。框里面有一张表,我想点击这张表其中一个字段如:名称,怎么才能把这个名称传回给(ID="name")这个文本框了???

解决方案 »

  1.   

    在表的点击事件中,抓取parent页面的 ID ="name"的文本框,
    然后将相应的字段值cell赋给文本框.
    例如:
    parent.document.getElementById("name").value = cell[0].value ....
      

  2.   

    按钮的JS:
    var a = window.showModalDialog(...);
    弹出窗口上的JS
    window.returnValue =formValue;//formValue你要返回的值
      

  3.   

    我的表是GridView,,应该是它的哪个事件,我试了一下,好像都不行。。晕了
      

  4.   

    谈出一个框(用JS做的)
    这个框是div还window,还是iframe
      

  5.   

    js是怎么打开这个window的?
      

  6.   

    你那个弹出的框是什么?div?还是窗口?
    例子1:div的<html>
    <head>
    <script type="text/javascript">
    function showWindow()
    {
      //document.all.winchild.style = "display:yes";
      document.getElementById("winchild").style.display="block";
    }
    function returnValue()
    {
      document.getElementById("text2").value = document.getElementById("text1").value;
      document.getElementById("winchild").style.display="none";
    }
    </script>
    </head>
    <body>
    <div id="winchild" style="display:none">
    <input type="textbox" value="" id="text1"/>
    <input type="button" value="ok" id="button1" onclick="returnValue()"/>
    </div>
    <div id="main">
    <input type="textbox" value="" id="text2"/>
    <input type="button" value="open" id="button2" onclick="showWindow()"/>
    </div>
    </body>
    </html>例子2:窗口
    1.html<html>
    <head>
    <script type="text/javascript">
    function showWindow()
    {
      window.open("2.html");
    }
    function returnValue(rtValue)
    {
      document.getElementById("text2").value = rtValue;
    }
    </script>
    </head>
    <body><div id="main">
    <input type="textbox" value="" id="text2"/>
    <input type="button" value="open" id="button2" onclick="showWindow()"/>
    </div>
    </body>
    </html>2.html<html>
    <body>
    <div id="main">
    <input type="textbox" value="" id="text1"/>
    <input type="button" value="ok" id="button1" onclick="javascript:window.opener.returnValue(document.getElementById('text1').value)"/>
    </div>
    </body>
    </html>
      

  7.   


     function OpenGoodsName(obj)
      {
            var iHeight="500px";
            var iWidth="786px";
            var iTop = event.screenY - event.offsetY + 20;
            var iLeft = event.screenX - event.offsetX - 4 - 175;
            var returnValue;
            returnValue=window.showModalDialog("Default8.aspx",window,"dialogHeight="+iHeight+";dialogWidth="+iWidth+";dialogTop="+iTop+"px;dialogLeft="+iLeft+"px;help=0;center=1;resizable=0;status=0;scroll=0");
            if(returnValue!=null)
            {
            obj.value=returnValue;
            }
            return false;
     }
      

  8.   

    首先确定 你的框框 是什么形式的,然后写JS函数 来响应click
    之后 在给需要的单元格添上 事件
      

  9.   

    LZ的gridview应该在生成时遍历单元格,给单元格加上点击的js,
    类似于单元格.attributes.add(onclick,"window.openner.document.getElementById('name').value=this.innerHTML");
      

  10.   

    在弹出框框的gridview 的RowDataBound事件里这样写protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //第i列
                e.Row.Cells[i].Attributes.Add("onclick", 
                  "window.dialogArguments.document.getElementById('name').value=this.innerText;");
            }
        }也可以在gridview 的绑定事件后写
                foreach (GridViewRow gr in gv.Rows)
                {
                    gr.Cells[i].Attributes.Add("onclick", 
    "window.dialogArguments.document.getElementById('name').value=this.innerText;");             }
      

  11.   

    不要使用innerHTML来设置text 的value用showModalDialog 打开的页 也不能用window.openner 来获得引用在传递的时候设置第二个参数,然后用window.dialogArguments 来获得引用
      

  12.   

    汗一个,两重循环啊
    foreach(GridViewRow row in gridview.rows )
    {
    foreach(TableCell cell in row.cells )
    {
    //todo
    }
    }
      

  13.   

    参考:http://blog.csdn.net/insus/archive/2008/03/26/2221227.aspx
      

  14.   

    事件加上了,运行没报错,但是GridView上都点不了。激发不了JS,这是什么原因??
      

  15.   

    <html>
    <head>
    <script type="text/javascript">
    function showWindow()
    {
      //document.all.winchild.style = "display:yes";
      document.getElementById("winchild").style.display="block";
    }
    function returnValue()
    {
      document.getElementById("text2").value = document.getElementById("text1").value;
      document.getElementById("winchild").style.display="none";
    }
    </script>
    </head>
    <body>
    <div id="winchild" style="display:none">
    <input type="textbox" value="" id="text1"/>
    <input type="button" value="ok" id="button1" onclick="returnValue()"/>
    </div>
    <div id="main">
    <input type="textbox" value="" id="text2"/>
    <input type="button" value="open" id="button2" onclick="showWindow()"/>
    </div>
    </body>
    </html>
      

  16.   


    在RowDataBound事件里写的么?
      

  17.   

    foreach(GridViewRow row in gridview.rows )  
    {  
    foreach(TableCell cell in row.cells )  
    {  
    //我不确定Sandy945 所说的用showModalDialog 打开的页 也不能用window.openner 来获得引用 ,我没有试过,你具体自己调试下cell.attributes.add(onclick,"window.openner.document.getElementById('name').value=this.innerHTML"); }  

      

  18.   

    日,都什么呀。
    在弹出的页面按钮里面写js:onclick="opener.document.getEleMentById('name').value=this.value"js代码是直接可以写到事件里面的。