关于jquery和子页面向父页面传值

来源:互联网 发布:mac用什么杀毒软件 编辑:程序博客网 时间:2024/05/22 03:49

原文转自:http://zhidao.baidu.com/question/129542051.html

关于jquery和子页面向父页面传值

刚接触jquery遇到问题了。想用jquery实现这样一个功能:例如当father页面的一个文本框(txtEmployee)输入控件获得焦点的时候。弹出一个子页面child.aspx:child页面中放的是一个repeater控件绑定的Employee表中的数据,双击repeater控件某一行的时候,将这行数据的Name值返回到father页面的txtEmployee文本框中。同时关闭child页面。代码如下:father.aspx<head runat="server">    <title>无标题页</title>    <script src="js/jquery-1.3.2.min.js" type="text/javascript"></script>    <script type="text/javascript">    $(document).ready(function() {            $("#txtEmployeeID").focus(function() {                parent.openDialog("child", "?page=father&custName=txtEmployee");            });        });    </script></head><body>    <form id="form1" runat="server">    <div>     <asp:TextBox ID="txtEmployee" runat="server"></asp:TextBox>    </div>    </form>/////////////////child.aspx绑定repeater主要代码    <div class="rept" style="width: 530px; height: 268px;">        <table cellpadding="0" cellspacing="0">            <tr id="0">                <th style="width: 10%">员工编号</th>                <th style="width: 10%">员工所属部门</th>                <th style="width: 9%">姓名</th>                <th style="width: 9%">职务</th>                <th style="width: 9%"> 性别</th>            </tr>            <asp:Repeater ID="reptE" runat="server">                <ItemTemplate>                    <tr id="<%# Eval("Employee_ID") %>" title='<%# Eval("Name") %>'>                        <td><%#Eval("Employee_ID")%></td>                        <td><%#Eval("Dept_ID")%></td>                        <td><%#Eval("Name")%></td>                        <td><%#Eval("Duty")%></td>                        <td><%#Eval("Gender")%></td>                    </tr>                </ItemTemplate>            </asp:Repeater>        </table>现在问题:1、在father页面中txtEmployee获得焦点的时候不弹出子页面。          2、在子页面中双击repeater某行的时候如何获取到相应的Name值。 
最佳答案
1. parent.openDialog("child", "?page=father&custName=txtEmployee");问号前面具体的页面写上不就行了。或者直接用window.open()不也行吗2.写一个函数:function quzhi(obj){var name=$("#" + obj.id + " td").eq(2).text();return name;}这就是取得name的值,obj是传入一个tr 
0 0
原创粉丝点击