问题描述
我在一个页面中有多个iframe,每个页面都包含一个表单,并且我将提交按钮放在iframe之外,并且当用户按提交所有表单时应该提交,然后页面应该关闭,任何人都可以帮助我吗?
这个函数叫onclick on submit button
function Save_Close()
{
if(window.frames.intake_pat_info_iframe&& window.frames.intake_pat_info_iframe._Submit('Update')){
window.frames.intake_pat_info_iframe._Submit ( '更新');
$ b $ if(window.frames.intake_job_info_iframe& window.frames.intake_job_info_iframe._Submit('Update')){
window.frames.intake_job_info_iframe._Submit( '更新');
$ b $ if(window.frames.intake_spine_his_iframe& window.frames.intake_spine_his_iframe._Submit('Update')){
window.frames.intake_spine_his_iframe._Submit( '更新');
if(window.frames.intake_past_med_history_iframe& window.frames.intake_past_med_history_iframe._Submit('Update')){
window.frames.intake_past_med_history_iframe._Submit( '更新');
}
....
< input type =buttonid =name =value =Save& Closeonclick =Save_Close()/>
thnx
只要你可以使用Javascript,并且你的iframe全部来自同一台服务器,那就不那么难。一个完全纯粹的内联JS方法看起来像(这是使用ASP.NET作为服务器端的东西,但重要的是按钮中的onclick()处理程序)
<%@ Page Language =C#%>
<!DOCTYPE html PUBLIC - // W3C // DTD XHTML 1.0 Strict // ENhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
< head>
< title> IFRAME表单提交演示< / title>
< / head>
< body>
< iframe name =iframe1src =my_form.aspx>< / iframe>
< iframe name =iframe2src =my_form.aspx>< / iframe>
< iframe name =iframe3src =my_form.aspx>< / iframe>
< iframe name =iframe4src =my_form.aspx>< / iframe>
< input type =submitvalue =Submit All IFrames
onclick =for(var i = 0; i< frames.length; i ++){frames [i] .document。 forms [0] .submitButton.click();}/>
< / body>
< / html>
编辑:现在显式调用form.submitButton.click()而不是form.submit()来调用函数绑定提交按钮的Click处理程序。
I'm having multiple iframes in one page each one contains a form , and i put the submit button outside the iframes , and when user press on submit all forms should be submited and then the page should be closed , any one can help me in this?
this function called onclick on submit button
function Save_Close()
{
if (window.frames.intake_pat_info_iframe && window.frames.intake_pat_info_iframe._Submit('Update')) {
window.frames.intake_pat_info_iframe._Submit('Update');
}
if (window.frames.intake_job_info_iframe && window.frames.intake_job_info_iframe._Submit('Update')) {
window.frames.intake_job_info_iframe._Submit('Update');
}
if (window.frames.intake_spine_his_iframe && window.frames.intake_spine_his_iframe._Submit('Update')) {
window.frames.intake_spine_his_iframe._Submit('Update');
}
if (window.frames.intake_past_med_history_iframe && window.frames.intake_past_med_history_iframe._Submit('Update')) {
window.frames.intake_past_med_history_iframe._Submit('Update');
}
....
<input type="button" id="" name="" value="Save & Close" onclick="Save_Close()"/>
thnx
As long as you can use Javascript and your iframes are all being served from the same server, it's not that hard. A completely pure inline JS approach looks like (this is using ASP.NET for the server-side stuff but the important bit is the onclick() handler in the button)
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>IFRAME form submit demo</title>
</head>
<body>
<iframe name="iframe1" src="my_form.aspx"></iframe>
<iframe name="iframe2" src="my_form.aspx"></iframe>
<iframe name="iframe3" src="my_form.aspx"></iframe>
<iframe name="iframe4" src="my_form.aspx"></iframe>
<input type="submit" value="Submit All IFrames"
onclick="for(var i = 0; i < frames.length; i++) { frames[i].document.forms[0].submitButton.click(); }" />
</body>
</html>
EDIT: now explicitly calls form.submitButton.click() instead of form.submit() to invoke functions bound to submit button's Click handler.
这篇关于提交多个表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!