弹出页面处理例子

本文介绍了一个JSP页面中实现员工选择功能的方法。通过禁用文本框展示员工名称,并使用按钮触发弹窗对话框进行员工搜索。该弹窗支持不同浏览器特性,如IE和Firefox,并能将选中员工的信息回传给父窗口。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[color=red]jsp页面控件:[/color]
<input class="" type="text" size="15" disabled="disabled" value="社員選択" id="empname"> <input type="button" id="empbtn" value="選択" style="width:50;" disabled="disabled" οnclick="opendialog()">

[color=red]js:[/color]function opendialog()
{
var srcFile = "../callsearchnew/empSearch.action";
var retValue = null;
if(navigator.userAgent.indexOf("MSIE")>0){
var winFeatures = "dialogHeight:300px;dialogWidth:500px;edge:sunken;scroll:no;status:no;help:no";
retValue = window.showModalDialog(srcFile,self,winFeatures);
}else if(navigator.userAgent.indexOf("Firefox")>0)
{
var fireFeatures = "dialogHeight:300px;dialogWidth:500px;edge:sunken;scroll:no;status:no;help:no";
//window.open( srcFile,null,fireFeatures);
retValue = window.showModalDialog(srcFile,null,fireFeatures);
}
}


function [color=darkred]setSelectedEmp[/color](name,id)
{
$("#empname").attr("value",name);
$("#hiddencollectioner").attr("value",name);
$("#hiddencollectionerno").attr("value",id);
if (name!=null)
{
document.getElementById("empname").focus();
}
}

[color=red]struts-call-config.xml配置文件[/color]
<action name="empSearch" class="empSearchAction" method="init">
<result name="success">/callsystem/callsearchnew/empSearch.jsp
</result>
</action>


[color=red][color=green]//empSearch.action 对应的jsp,返回父页面的js[/color][/color]

function doConfirm(){
var empnovalue = document.getElementById("empnovalue").value;
if(empnovalue == ""){
alert("社員選択はしていません。");
window.close();
}
var empId = empnovalue.split(":")[0];//社員CD
var empName = empnovalue.split(":")[1];//社員名
var fatherDnt = null;
if(navigator.userAgent.indexOf("MSIE")>0) {
fatherDnt = window.dialogArguments;
}else if (navigator.userAgent.indexOf("Firefox")>0) {
fatherDnt = opener;
}
//[color=green]传给父窗口js:setSelectedEmp方法参数[/color]
fatherDnt.[color=darkred]setSelectedEmp[/color](empName, empId);
window.close();
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值