我可以将PayPal按钮集成到我的HTML中吗?

时间:2015-07-14 06:10:17

标签: javascript html paypal

我在向HTML添加PayPal按钮时遇到了一些问题。不确定它是否可能,但我希望它能够通过PayPal“立即购买”按钮按下JavaScript时产生的价格输出并允许他们购买产品。如果有人能告诉我这是可行的,那将非常感激。

到目前为止我的代码:

    <!DOCTYPE html>
<!-- boost script by thelamp  -->
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">

    <script>
        var costs = [ 10,10,10,10,10,
                      15,15,15,15,15,
                      20,20,20,20,20,
                      25,25,25,25,25,
                      30,30,30,30,30];

        function calc() {
            var fromValue = document.getElementById("from").selectedIndex;

            var toValue = document.getElementById("to").selectedIndex;

            if (fromValue < toValue) {
                var price = 0;

                for (i = fromValue; i < toValue; i++) {
                    price += costs[i];
                }

                document.getElementById("price").innerHTML = price;
            } else {
                document.getElementById("price").innerHTML = 'Target Rank needs to be higher than the your Rank.';
            }
        }
    </script>
</head>
    <body>


    From:
        <select id="from" onchange="calc()">
            <option>Silver 1</option>
            <option>Silver 2</option>
            <option>Silver 3</option>
            <option>Silver 4</option>
            <option>Silver Elite</option>
            <option>Silver Elite Master</option>
            <option>Gold Nova 1</option>
            <option>Gold Nova 2</option>
            <option>Gold Nova 3</option>
            <option>Gold Nova Master</option>
            <option>Master Guardian 1</option>
            <option>Master Guardian 2</option>
            <option>Master Guardian Elite</option>
            <option>Distinguished Master Guardian</option>
            <option>Legendary Eagle</option>
            <option>Legendary Eagle Master</option>
            <option>Supreme Master First Class</option>
            <option>Global Elite</option>
        </select>

        To:
        <select id="to" onchange="calc()">
            <option>Silver 1</option>
            <option>Silver 2</option>
            <option>Silver 3</option>
            <option>Silver 4</option>
            <option>Silver Elite</option>
            <option>Silver Elite Master</option>
            <option>Gold Nova 1</option>
            <option>Gold Nova 2</option>
            <option>Gold Nova 3</option>
            <option>Gold Nova Master</option>
            <option>Master Guardian 1</option>
            <option>Master Guardian 2</option>
            <option>Master Guardian Elite</option>
            <option>Distinguished Master Guardian</option>
            <option>Legendary Eagle</option>
            <option>Legendary Eagle Master</option>
            <option>Supreme Master First Class</option>
            <option>Global Elite</option>
        </select>
        <br><br>

        Price:
        <div id="price">

        </div>
    </body>
</html>

1 个答案:

答案 0 :(得分:0)

<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="oceLoL">
<input type="hidden" name="lc" value="AU">

<input type="hidden" name="item_name" value="test">
<input type="hidden" name="amount" value= "1"> 

<input type="hidden" name="currency_code" value="AUD">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynow_SM.gif:NonHosted">
<input type="image" src="https://www.paypalobjects.com/en_AU/i/btn/btn_buynow_SM.gif" border="0" name="submit" alt="PayPal – The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_AU/i/scr/pixel.gif" width="1" height="1">
</form>

</body>

嗨,关注上述问题,您如何将用户选择拉入paypal详细信息?

关于以下编码:           

'项目名称'值应基于用户选择的内容,即“银1至金新星1” '金额值'应该是相同的情况,并且基于用户的选择。