0

我在我的音乐团体的网站上为部分季票套餐销售创建了一个脚本。用户将选择 4 个音乐会节目,然后为每个所选音乐会节目选择日期。所有这些选择都需要发布到 Paypal 进行处理/购买。我的“添加到购物车”按钮确实会发送到 Paypal,但音乐会节目和日期没有被选中。票房人士需要这些信息。你可以在这里看到我的代码:http: //jsfiddle.net/saraswati/v6Pur/66/

这是HTML:

<form target="paypal" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post"><strong><a name="Partial">Partial</a> subscription (4 concerts), Regular Price: $87.00 (a savings of 13%)</strong>
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="add" value="1">
<input type="hidden" name="business" value="temp_1344946752_biz@me.com">
<input type="hidden" name="item_name" value="Partial subscription (4 concerts), Regular Price">
<input type="hidden" name="amount" value="87.00">
<input type="hidden" name="currency_code" value="USD">

<table width="90%" cellspacing="0" cellpadding="0" border="1">
<CAPTION>Please select the desired concert program and then the desired date from the pull-down menus. Then click the "Add to Cart" button.</CAPTION>

<tr id="row1" align=center>
<td><font color="#990000">Concert 1:</font></td>
<td><font color="#990000">Concert 2:</font></td>
<td><font color="#990000">Concert 3:</font></td>
<td><font color="#990000">Concert 4:</font></td>
</tr>
<tr id=row2>
<td><input type="hidden" name="os0" value="Concert 1"><body onload="ChangeDateDropList ();">   
    <select id="program1" onchange="ChangeDateDropList(1);"> 
        <option value="" selected="selected">Select a Program</option> 
        <option value="TUDORS">The Tudors</option> 
        <option value="NOCHES">Noches, Noches</option> 
        <option value="CHRISTMAS">Christmas Eurotour</option> 
        <option value="CELTIC">Celtic Trinity</option>
        <option value="UNREQUITED">Unrequited Love</option>
        <option value="SECRET">Secret No More</option> 
    </select> 

    <select id="date1"> 
    </select> 
</body>
</td>

<td><input type="hidden" name="os1" value="Concert 2"><body onload="ChangeDateDropList ();">   
    <select id="program2" onchange="ChangeDateDropList(2);"> 
        <option value="" selected="selected">Select a Program</option> 
        <option value="TUDORS">The Tudors</option> 
        <option value="NOCHES">Noches, Noches</option> 
        <option value="CHRISTMAS">Christmas Eurotour</option> 
        <option value="CELTIC">Celtic Trinity</option>
        <option value="UNREQUITED">Unrequited Love</option>
        <option value="SECRET">Secret No More</option> 
    </select> 

    <select id="date2"> 
    </select>
</body> 
</td>

<td><input type="hidden" name="os2" value="Concert 3"><body onload="ChangeDateDropList ();">   
    <select id="program3" onchange="ChangeDateDropList(3);"> 
        <option value="" selected="selected">Select a Program</option> 
        <option value="TUDORS">The Tudors</option> 
        <option value="NOCHES">Noches, Noches</option> 
        <option value="CHRISTMAS">Christmas Eurotour</option> 
        <option value="CELTIC">Celtic Trinity</option>
        <option value="UNREQUITED">Unrequited Love</option>
        <option value="SECRET">Secret No More</option> 
    </select> 

    <select id="date3"> 
    </select> 
</body>
</td>

<td><input type="hidden" name="os3" value="Concert 4"><body onload="ChangeDateDropList ();">   
    <select id="program4" onchange="ChangeDateDropList(4);"> 
        <option value="" selected="selected">Select a Program</option> 
        <option value="TUDORS">The Tudors</option> 
        <option value="NOCHES">Noches, Noches</option> 
        <option value="CHRISTMAS">Christmas Eurotour</option> 
        <option value="CELTIC">Celtic Trinity</option>
        <option value="UNREQUITED">Unrequited Love</option>
        <option value="SECRET">Secret No More</option> 
    </select> 

    <select id="date4"> 
    </select> 
</body>
</td>
</tr>
</table>
<br>
<center>
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_cart_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
</center>

这是Javascript:

 var progamsAndDates = {};
    progamsAndDates.TUDORS = ['Sept. 15', 'Sept. 16'];
    progamsAndDates.NOCHES = ['Oct. 20', 'Oct. 21'];
    progamsAndDates.CHRISTMAS = ['Dec. 14', 'Dec. 15', 'Dec. 16'];
    progamsAndDates.CELTIC = ['Jan. 26', 'Jan. 27'];
    progamsAndDates.UNREQUITED = ['Mar. 02', 'Mar. 03'];
    progamsAndDates.SECRET = ['Apr. 20', 'Apr. 21'];

    function ChangeDateDropList (id) { 

        var programDropList = document.getElementById ("program"+id);
        var dateDropList = document.getElementById ("date"+id);
        var selProgram = programDropList.options[programDropList.selectedIndex].value;

        // remove all dates
        while (dateDropList.options.length) {
            dateDropList.remove (0);
        }

        // add new dates
        var dates = progamsAndDates[selProgram];
        if (dates) {
            for (var i=0; i < dates.length; i++) {
                var date = new Option (dates[i], i);
                dateDropList.options.add (date);
            }
        }
    } 

同样,当我单击“添加到购物车”按钮时,它转到 Paypal,描述为“部分订阅(4 场音乐会),常规价格”,它会显示商品价格等。但是,描述也应该显示选择,例如“都铎王朝,9 月 15 日;凯尔特人,1 月 27 日;等等。” 我质疑你们所有人在实现这一目标方面的智慧。谢谢!

4

1 回答 1

0

您传递的变量不正确。您正在传递变量,例如 on0、os0、on1、os1。这些对于添加到购物车按钮或立即购买按钮是正确的,但是由于您使用的是购物车上传方法,因此它们需要像 on0_1、os0_1、on1_2 和 os1_2 一样传递。这将纠正您的问题,然后它们应该会出现。

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="my_email@my_site.com">

<input type="hidden" name="item_name_1" value="Football T-Shirt">
<input type="hidden" name="amount_1" value="1.00">
<input type="hidden" name="on0_1" value="Color">
<input type="hidden" name="os0_1" value="Red">
<input type="hidden" name="on1_1" value="Size">
<input type="hidden" name="os1_1" value="Small">

<input type="hidden" name="item_name_2" value="Notebook">
<input type="hidden" name="amount_2" value="2.00">
<input type="hidden" name="on0_2" value="Number of Pages">
<input type="hidden" name="os0_2" value="200">
<input type="hidden" name="on1_2" value="Type">
<input type="hidden" name="os1_2" value="3 Ring">

<input type="submit" value="PayPal">
</form>
于 2013-04-05T20:50:04.470 回答