Paypal没有选择选择

时间:2013-04-05 14:58:29

标签: javascript paypal

我已经在我的音乐组网站上为部分季票套餐销售创建了一个脚本。用户将选择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日;等等”我要问你所有人的智慧,让它发挥作用。谢谢!

1 个答案:

答案 0 :(得分: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>