Colorbox弹出窗口通过表单提交取消

时间:2014-02-21 08:56:03

标签: javascript php html forms colorbox

我有一个颜色框,根据用户输入和数据库值调用PHP页面。问题是:

当我注释掉“document.getElementById(formID).submit();”时下面,颜色框打开正常。当它被放入时,或者当彩色盒调用被删除后“返回false”时,彩色盒只会短暂打开,只有白色内容,然后立即关闭。

这绝对与colorbox调用的PHP页面无关,因为它在表单提交不会发生时工作正常(并且相同的colorbox调用在另一个不涉及表单提交的函数中工作正常)。但我确实需要在客户点击OK时提交表单!

function reactivate_customer_account (formID, user, server, wowzaStatus, kundenNummer) {

        var answer = confirm (unescape("Do you want to reactivate the user account?")); 

        if (!answer) return false;

        document.getElementById(formID).submit(); // this appears to cause the problem!

        if (wowzaStatus == 999) { 

            $.colorbox({ href: "https://webpageaddress.de/script.php?request=reactivate&user=" + user + "&server=" + server + "&KdNr=" + kundenNummer, iframe: true, width: 450 + "px", height: 700 + "px", transition: "fade" });
            return false;

        }  

    }

function reactivate_customer_account (formID, user, server, wowzaStatus, kundenNummer) { var answer = confirm (unescape("Do you want to reactivate the user account?")); if (!answer) return false; document.getElementById(formID).submit(); // this appears to cause the problem! if (wowzaStatus == 999) { $.colorbox({ href: "https://webpageaddress.de/script.php?request=reactivate&user=" + user + "&server=" + server + "&KdNr=" + kundenNummer, iframe: true, width: 450 + "px", height: 700 + "px", transition: "fade" }); return false; } }

调用此函数的代码:

<form id='kunden_reaktivieren_form_{$row['id']}' method='post' action='' onsubmit='return reactivate_customer_account(\"kunden_reaktivieren_form_{$row['id']}\", \"{$row['FTP_download_benutzername']}\", \"$kunden_server_name\", \"{$row['WowzaStatus']}\", {$row['Kundennummer']});'>

<input type='hidden' name='session_key' value='$session_key'/>
<input type='submit' value='Kunden AKTIVIEREN'/>
...
</form>

感谢任何帮助和解释问题是什么!谢谢!

1 个答案:

答案 0 :(得分:0)

当你这样做时:

document.getElementById(formID).submit();

您的页面将刷新,并且不会执行以下代码。如果您希望打开colorbox,则应通过AJAX调用表单提交。

jQuery $.ajax$.post会对您有所帮助。