52,784
社区成员
发帖
与我相关
我的任务
分享 function dlgopen1() {
$.dialog({
id: 'id001',
title: '确认订单',
width: 700,
height: 500,
lock: true,
max: false,
min: false,
content: 'url:test.aspx' //我想POST数据到test.aspx这个页面
});
}
好办法[/quote]
大牛,这样不行吧。[/quote]
哦,是会有点问题,这种做法需要iframe提前就存在,你可以先写一个iframe
<form action="test.aspx" target="id001" id="form1">
<iframe id='id001' name='id001'></iframe>
要弹出层时提交表单
function dlgopen1() {
$('#form1').submit();
$.dialog({
id: 'id001',
title: '确认订单',
width: 700,
height: 500,
lock: true,
max: false,
min: false,
content: '#id001' //
});
}[/quote]
不知道还有其它方法吗?这样不太好啊……。[/quote]
其他方法都需要用js了
1.
ajax提交
用ajax将几个表单项值提交给服务端,服务端根据值返回相应的页面代码,(C#用Response.ReadRect),然后回调函数中将响应弹出来
2.
可以用js获取父页面标签
在子页面中用window.parent可以获取父页面window对象,进而获取到父页面的所有html值
如:
var val1=$(window.parent.document).find('input[name=name1]').val();
这句可以在子页面获取到父页面name为name1的文本框输入值
对你来说估计比上面说的更难
好办法[/quote]
大牛,这样不行吧。[/quote]
哦,是会有点问题,这种做法需要iframe提前就存在,你可以先写一个iframe
<form action="test.aspx" target="id001" id="form1">
<iframe id='id001' name='id001'></iframe>
要弹出层时提交表单
function dlgopen1() {
$('#form1').submit();
$.dialog({
id: 'id001',
title: '确认订单',
width: 700,
height: 500,
lock: true,
max: false,
min: false,
content: '#id001' //
});
}[/quote]
iframe还没存在。。先打开对话框生成iframe,增加init事件,事件中再提交表单
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="http://elonan.com/test/jquery-1.7.2.min.js"></script>
<script src="http://elonan.com/test/lhgdialog/lhgdialog.min.js?self=false"></script>
<script type="text/javascript">
function dlgopen1() {
$.dialog({
id: 'id001',
title: '确认订单',
width: 700,
height: 500,
lock: true,
max: false,
min: false,
init: function () { document.postFrm.submit() },
content: 'url:about:blank' //这个地址随便设置,主要为是了生成iframe用的,为了不和服务器交互,设置为about:blank
});
}
</script>
</head>
<body>
<form name="postFrm" action="http://elonan.com/test/test.asp" target="id001" method="post">
<input id="name" name="name" type="text" />
<br />
<input id="Button_open" type="button" onclick="javascript:dlgopen1();" value="post input到test.asp"
name="Button_open" />
</form>
</body>
</html>
好办法[/quote]
大牛,这样不行吧。[/quote]
哦,是会有点问题,这种做法需要iframe提前就存在,你可以先写一个iframe
<form action="test.aspx" target="id001" id="form1">
<iframe id='id001' name='id001'></iframe>
要弹出层时提交表单
function dlgopen1() {
$('#form1').submit();
$.dialog({
id: 'id001',
title: '确认订单',
width: 700,
height: 500,
lock: true,
max: false,
min: false,
content: '#id001' //
});
}[/quote]
不知道还有其它方法吗?这样不太好啊……。
好办法[/quote]
大牛,这样不行吧。[/quote]
哦,是会有点问题,这种做法需要iframe提前就存在,你可以先写一个iframe
<form action="test.aspx" target="id001" id="form1">
<iframe id='id001' name='id001'></iframe>
要弹出层时提交表单
function dlgopen1() {
$('#form1').submit();
$.dialog({
id: 'id001',
title: '确认订单',
width: 700,
height: 500,
lock: true,
max: false,
min: false,
content: '#id001' //
});
}
好办法[/quote]
大牛,这样不行吧。
好办法<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="http://elonan.com/test/jquery-1.7.2.min.js"></script>
<script src="http://elonan.com/test/lhgdialog/lhgdialog.min.js?self=false"></script>
<script type="text/javascript">
function dlgopen1() {
$.dialog({
id: 'id001',
title: '确认订单',
width: 700,
height: 500,
lock: true,
max: false,
min: false,
content: 'url:http://elonan.com/test/test.asp' //我想POST数据到test.aspx这个页面
});
}
</script>
</head>
<body>
<form action="http://elonan.com/test/test.asp" target="id001" method="post">
<input id="name" name="name" type="text" />
<br />
<input id="Button_open" type="button" onclick="javascript:dlgopen1();" value="post input到test.asp"
name="Button_open" />
</form>
</body>
</html>
测试脚本:http://elonan.com/test/test.rar
版主能帮我测试下吗?完全没有效果啊。
function dlgopen1() {
$.dialog({
id: 'id001',
title: '确认订单',
width: 700,
height: 500,
lock: true,
max: false,
min: false,
init: function () {
if (window.ActiveXObject) { //IE直接替换掉原来的iframe
var pNode = lhgdialog.list['id001'].iframe.parentNode;
pNode.removeChild(lhgdialog.list['id001'].iframe)//删除原来的iframe
$('<iframe name="id001" style="width:100%;height:100%;border:none 0;"></iframe>').appendTo(pNode);
}
document.postFrm.submit()
},
content: 'url:about:blank' //这个地址随便设置,主要为是了生成iframe用的,为了不和服务器交互,设置为about:blank
});
}
好办法[/quote]
大牛,这样不行吧。[/quote]
哦,是会有点问题,这种做法需要iframe提前就存在,你可以先写一个iframe
<form action="test.aspx" target="id001" id="form1">
<iframe id='id001' name='id001'></iframe>
要弹出层时提交表单
function dlgopen1() {
$('#form1').submit();
$.dialog({
id: 'id001',
title: '确认订单',
width: 700,
height: 500,
lock: true,
max: false,
min: false,
content: '#id001' //
});
}[/quote]
不知道还有其它方法吗?这样不太好啊……。[/quote]
其他方法都需要用js了
1.
ajax提交
用ajax将几个表单项值提交给服务端,服务端根据值返回相应的页面代码,(C#用Response.ReadRect),然后回调函数中将响应弹出来
2.
可以用js获取父页面标签
在子页面中用window.parent可以获取父页面window对象,进而获取到父页面的所有html值
如:
var val1=$(window.parent.document).find('input[name=name1]').val();
这句可以在子页面获取到父页面name为name1的文本框输入值
对你来说估计比上面说的更难[/quote]
谢谢wzs_xyz:
lhgdialog提供了获取父页面值的API,但由于业务需求,我不能这样获取。因为JS的执行永远比后台Page_Load慢,而我要在Page_Load执行一些操作。
好办法[/quote]
大牛,这样不行吧。[/quote]
哦,是会有点问题,这种做法需要iframe提前就存在,你可以先写一个iframe
<form action="test.aspx" target="id001" id="form1">
<iframe id='id001' name='id001'></iframe>
要弹出层时提交表单
function dlgopen1() {
$('#form1').submit();
$.dialog({
id: 'id001',
title: '确认订单',
width: 700,
height: 500,
lock: true,
max: false,
min: false,
content: '#id001' //
});
}[/quote]
iframe还没存在。。先打开对话框生成iframe,增加init事件,事件中再提交表单
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="http://elonan.com/test/jquery-1.7.2.min.js"></script>
<script src="http://elonan.com/test/lhgdialog/lhgdialog.min.js?self=false"></script>
<script type="text/javascript">
function dlgopen1() {
$.dialog({
id: 'id001',
title: '确认订单',
width: 700,
height: 500,
lock: true,
max: false,
min: false,
init: function () { document.postFrm.submit() },
content: 'url:about:blank' //这个地址随便设置,主要为是了生成iframe用的,为了不和服务器交互,设置为about:blank
});
}
</script>
</head>
<body>
<form name="postFrm" action="http://elonan.com/test/test.asp" target="id001" method="post">
<input id="name" name="name" type="text" />
<br />
<input id="Button_open" type="button" onclick="javascript:dlgopen1();" value="post input到test.asp"
name="Button_open" />
</form>
</body>
</html>
[/quote]
十分感谢版主的帮助,经过用ietest测试,你的代码在IE6/IE7有问题,IE9/IE10的兼容性视图下也不能正常运行
点击按钮后,会自动弹出二个页面
测试地址:http://www.elonan.com/test/test.htm