0

我有这个:

HTML

这是一个在模式窗口中打开 href 的按钮:

<a class="iframe button pink" href="http://www.test.php" > Pay Now <link rel="stylesheet" href="http://www.fethr.com/clients/res/buttonmodal.css">

表格:

<form method="post" />
<input type="text" name="xx" />
<input type="text" name="yy" />


 <a class="iframe button pink" href="http://www.test.php" > Pay Now <link rel="stylesheet" href="http://www.fethr.com/clients/res/buttonmodal.css">
    <script src="http://www.fethr.com/clients/res/buttonmodal.js"></script></a>

</form>

这个锚按钮。如果我单击它,它将在模式窗口中打开 href。我正在尝试将其用作提交按钮并将值发布到 href 以及在模式窗口中打开它。这可能吗?

4

1 回答 1

0

这是一个关于如何实现此目标的简单示例:

HTML

<form method="post" onsubmit="return openModal()">
    <input type="hidden" name="price" class="price" value="100.00">
    <input type="submit" class="submit" value="Pay Now">
</form>

<div id="modal" style="display:none"></div>

Javascript

function openModal(){
    // when you click the submit button
    $('.submit').click(function(){
        // Add an iframe inside the modal window, throw in the form value into the src URL
        $('#modal').html('<iframe src="http://www.domain.com/checkout.php?price=' + $('.price').val() + '"></iframe>');
        // Display the modal window
        $('#modal').show();
    }
    // Don't submit this form (we don't want the page to reload)
    return false;
}

因此,在 iframe 的源文件中,您只需要获取 URL 参数并计算它们。

这是一个简单的示例,没有您提供的示例链接那么复杂(他们使用 Ajax 调用来实现此目的),但这应该可以帮助您入门。

于 2014-01-03T22:32:01.487 回答