Lotus教程、Java教程、Java虚拟机、Java软件综合开发社区

Lotus、Domino、Java、C#、Web、数据库综合开发教程、资料社区

window.showModalDialog 子窗口 给父窗口赋值 的使用



Published by admin on 07月 16, 2011

常见的在javascript中需要弹出一新窗口进行相关操作,而后需要将操作的值返回给父窗口

一般而言弹出窗口有window.open   和window.showModalDialog 等

window.showModalDialog 子窗口 给父窗口赋值 的使用方法
(1)
父窗口
<script language=”JavaScript” type=”text/javascript”>
function openwin() {
var rsName = window.showModalDialog(”RetailShopSelect.aspx”, “newwindow”, “dialogWidth:700px,dialogHeight:540px;center:Yes;resizable:no;status:no;scroll:no;”)
if (rsName != null && rsName != “”) {
var strs = new Array();
strs = rsName.split(” “);
window.document.getElementById(”tbxRSId”).value = strs[0];
window.document.getElementById(”tbxRSNameCn”).value = strs[1];
}
}
</script><tr>


<td>&nbsp;</td>
<td class=”style1″>用 户 名</td>
<td><asp:Label ID=”lblUserCode” runat=”server” ForeColor=”Red”></asp:Label></td>
<td class=”style1″>所 在 店</td>
<td>
<asp:TextBox ID=”tbxRSNameCn” runat=”server” Width=”105px”></asp:TextBox>
<asp:Button ID=”btnSelectRetailShop” runat=”server” Text=”选择店面” OnClientClick=”openwin()” Height=”25px” Width=”80px”/>
<input type=”hidden” ID=”tbxRSId” value=”" runat=”server”/></td>
<td>&nbsp;</td>
</tr>
子窗口
<base target=”_self” /> ——加上这一句话可以在子窗口进行一些操作,要是不加的话,比如查询会另弹出一个页面来
<script type=”text/javascript”>
function ReKey(rsName)//页面间传值
{
window.returnValue = rsName;
window.close();
}
</script>

<asp:TemplateField>
<HeaderTemplate>
<div style=”font-size:12px”>确认选择</div>
</HeaderTemplate>
<ItemTemplate>
<div align=”center” style=”font-size:12px”><a onclick=’javascript:ReKey(”<%#Eval(”id”)%> <%#Eval(”NameCn”)%>”)’>
<input id=”Button1″ class=”BigInput” type=”button” value=”确认选择” /></a> </div>
</ItemTemplate>
</asp:TemplateField>
window.showModalDialog 子窗口 给父窗口赋值 的使用方法
(2)
父窗口:

<script language=”JavaScript” type=”text/javascript”>
function openwin() {
var rsName = window.showModalDialog(”RetailShopSelect.aspx”, “newwindow”, “dialogWidth:700px,dialogHeight:540px;center:Yes;resizable:no;status:no;scroll:no;”)
if (rsName != null && rsName != “”) {
var strs = new Array();
strs = rsName.split(” “);
window.document.getElementById(”tbxRSId”).value = strs[0];
window.document.getElementById(”tbxRSNameCn”).value = strs[1];
}
}
</script>
<asp:TextBox ID=”tbxRSId” runat=”server” Width=”16px”></asp:TextBox>
<asp:TextBox ID=”tbxRSNameCn” runat=”server” Width=”105px”></asp:TextBox>

<asp:Button ID=”btnSelectRetailShop” runat=”server” Text=”选择店面” CssClass=”btn1″ onmouseover=”this.className=’btn2′;” onmouseout=”this.className=’btn1′;” OnClientClick=”openwin()” Height=”25px” Width=”80px”/>
子窗口:

<script type=”text/javascript”>
function ReKey(rsName)//页面间传值
{
window.returnValue = rsName;
window.close();
}
</script>

<asp:TemplateField>
<HeaderTemplate>
<div style=”font-size:12px”>确认选择</div>
</HeaderTemplate>
<ItemTemplate>
<div align=”center” style=”font-size:12px”><a onclick=’javascript:ReKey(”<%#Eval(”id”)%> <%#Eval(”NameCn”)%>”)’>
<input id=”Button1″ class=”BigInput” type=”button” value=”确认选择” /></a> </div>
</ItemTemplate>
</asp:TemplateField>

上一篇文章:« Java获取某月天数


【版权说明】:本网页上有部分内容来源于网上收集,但不能保证资料的完整性和准确性,仅提供参考和学习。如有侵权请立即通知我们,我们将立即删除,谢谢合作!

Add A Comment