Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Paypal购物车中创建多个选择选项框_Paypal - Fatal编程技术网

在Paypal购物车中创建多个选择选项框

在Paypal购物车中创建多个选择选项框,paypal,Paypal,是否可以使用多选框将项目提交到paypal购物车?我目前有一个javascript,它循环遍历选项,将它们附加到我的表单中,然后提交表单。但是,仅提交最后一项 代码如下: function getValues() { var os0 = document.getElementById("os0"); var options = os0 && os0.options; var price = 0; for (i=0; i < options.length; i++) {

是否可以使用多选框将项目提交到paypal购物车?我目前有一个javascript,它循环遍历选项,将它们附加到我的表单中,然后提交表单。但是,仅提交最后一项

代码如下:

function getValues() {
var os0 = document.getElementById("os0");
var options = os0 && os0.options;
var price = 0;
for (i=0; i < options.length; i++) {
  if(options[i].selected) {
    switch(i) {
      case 2:
      case 4:
      case 7:
      case 8:
        price = "30.00";
        break;
      case 0:
      case 1:
      case 3:
      case 5:
      case 6:
        price ="25.00";
        break;
      default:
        price ="25.00";
        break;  
    }

    $("#singleDungeon").append('<input type="hidden" name="option_select'+i+'" value="'+options[i].value+'"/>');
    $("#singleDungeon").append('<input type="hidden" name="option_amount'+i+'" value="'+price+'"/>');
  }
}
document.getElementById('singleDungeon').submit(); 
return true;
}
</script>
函数getValues(){
var os0=document.getElementById(“os0”);
var options=os0&&os0.options;
var价格=0;
对于(i=0;i
任何见解都值得赞赏


谢谢

成功了。如果没有使用正确的增量和语法,购物车系统将忽略项目。因此,将代码更改为item_uname_35;和amount_35;。此外,还添加了一个计数值,而不是使用索引值。所以它将是数量1,数量2,而不是数量6,等等

                      <div class="pt1">
                    <h2>Single Dungeons</h2>
                    <div class="price3">
                      <h1>$25 - $30</h1>
                      <p>&nbsp;</p>
                    </div>
                    <!--price-->
                      <div class="content">
                        <p>Bring any class!</p>
                      </div>
                      <div class="content">
                        <p>You play your character!</p>
                      </div>
                        <div class="content">
                        <input type="hidden" name="on0" value="Single Dungeon"/>
                        <select multiple="multiple" name="os0" id="os0">
                          <option value="Gate of the Setting Sun">Gate of the Setting Sun - $25</option>
                          <option value="Shado'pan Monastery">Shado'pan Monastery - $25</option>
                          <option value="Stormstout Brewery">Stormstout Brewery - $30</option>
                          <option value="Temple of the Jade Serpent">Temple of the Jade Serpent - $25</option>
                          <option value="Mogu'Shan Palace">Mogu'Shan Palace - $30</option>
                          <option value="Scholomance">Scholomance - $25</option>
                          <option value="Scarlet Halls">Scarlet Halls - $25</option>
                          <option value="Scarlet Monastery">Scarlet Monastery - $30</option>
                          <option value="Siege of Niuzao Temple">Siege of Niuzao Temple - $30</option>
                        </select>
                      </div>
                      <!--content-->
                      <form action='https://www.paypal.com/cgi-bin/webscr' method='post' target="paypal" id="singleDungeon" >
                        <input type="hidden" name="cmd" value="_cart">
                        <input type="hidden" name="upload" value="1">
                        <input type='hidden' name="business" value="daniil_kuranov1@hotmail.com">
                        <input type='hidden' name="currency_code" value="USD">
                        <input type="hidden" name="return" value="http://www.project-carry.com"/>
                        <input type="hidden" name="cancel_return" value="http://www.project-carry.com"/>
                        <input type="hidden" name="shopping_url" value="http://www.project-carry.com/buy-now.html">
                        </form>
                        <a href="#" onclick="getValues(); return false">Buy Now</a>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>            
function getValues() {
var os0 = document.getElementById("os0");
var options = os0 && os0.options;
var price = 0;
var count = 1;
for (i=0; i < options.length; i++) {
  if(options[i].selected) {
    switch(i) {
      case 2:
      case 4:
      case 7:
      case 8:
        price = "30.00";
        break;
      case 0:
      case 1:
      case 3:
      case 5:
      case 6:
        price ="25.00";
        break;
      default:
        price ="25.00";
        break;  
    }

    $("#singleDungeon").append('<input type="hidden" name="item_name_'+count+'" value="'+options[i].value+'" />');
    $("#singleDungeon").append('<input type="hidden" name="amount_'+count+'" value="'+price+'" />');
    count++;
  }
}
document.getElementById('singleDungeon').submit(); 
return true;
}
</script>

单一地下城
$25 - $30

带任何班级

你扮演你的角色

夕阳之门-25美元 沙多潘修道院-25美元 斯托斯托特啤酒厂-30美元 玉蛇庙-25美元 磨谷山宫-30美元 奖学金-$25 猩红大厅-25美元 猩红修道院-30美元 围攻牛灶寺-30美元 函数getValues(){ var os0=document.getElementById(“os0”); var options=os0&&os0.options; var价格=0; var计数=1; 对于(i=0;i