六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 45|回复: 0

子页面向父页面传值

[复制链接]

升级  41.33%

28

主题

28

主题

28

主题

秀才

Rank: 2

积分
112
 楼主| 发表于 2013-1-29 08:41:19 | 显示全部楼层 |阅读模式
想用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值。 提问者: bogeyman0 - 二级
最佳答案
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

转自:http://zhidao.baidu.com/question/129542051.html
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表