是否可以?!为 paypal 动态下拉菜单项指定动态名称

发布于 2024-10-28 00:25:37 字数 2811 浏览 1 评论 0原文

我有一个下拉菜单,它是从我的数据库中填充的。在填充列表后,我必须为每个 option_select 和 option_amount 提供一个条目,但它需要链接到该列表。有没有一种方法可以为每个选项提供一些将传递到 paypal 的信息,因为目前传递到 paypal 购物车的唯一信息是 "PHOTOID & " 但我无法让它发送所选的产品!啊啊!!请帮忙! 这是我的代码:

<form target="_self" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="MYEMAILADDRESS" />
<input type="hidden" name="cancel_return" value="website/cancel">

<!-- Specify an Add to Cart button. -->
<input type="hidden" name="cmd" value="_cart" />

<input type="hidden" name="add" value="1" />
<!-- Specify details about the item that buyers will purchase. -->
<input type="hidden" name="item_name" value="PHOTOID<?php echo $pid;?> <?php echo $product;?>" />
<input type="hidden" name="currency_code" value="GBP" />


<!-- Provide a dropdown menu option field with prices. -->
<!--<input type="hidden" name="on1" value="Size" />-->

<select name="os1">
<option value="Delivery Destination">-- Select --</option>
<?php 
$i = 0;?>
<?php $prices=MYSQL_QUERY( "select * from FESTpricelist");

while($pricelist=mysql_fetch_array( $prices )) 

{
$id = "".$pricelist['id']."";
$product = "".$pricelist['product'].""; 
$price = "".$pricelist['price']."";
?>

<option value="<?php echo $product;?>"><?php echo $product;?> £<?php echo $price;?> </option>

<?php } ?>

</select>

<br />

<!-- Specify the price that PayPal uses for each option. -->
<input type="hidden" name="option_index" value="1" />
<?php 
$i = 0;?>
<?php $prices=MYSQL_QUERY( "select * from FESTpricelist");

while($pricelist=mysql_fetch_array( $prices )) 

{
$id = "".$pricelist['id']."";
$product = "".$pricelist['product'].""; 
$price = "".$pricelist['price']."";
?>

<input type="hidden" name="option_select<?php echo $i;?>" value="<?php echo $product;?>" />
<input type="hidden" name="option_amount<?php echo $i;?>" value="<?php echo $price; ?>" />
<?php $i = $i + 1;
} ?>

<!-- specify shipping cost -->
<input type="hidden" name="shipping1" value="0" />

<!-- Display the payment button. 
<input type="image" name="submit" border="0" src="https://www.paypal.com/en_US/i/btn/btn_cart_LG.gif" alt="PayPal - The safer, easier way to pay online" />-->
<input type="image" src="images/1301261203_edit_add.png" border="0" name="submit" alt="PayPal - The safer, easier way to pay online.">

<img alt="paypal" border="0" width="1" height="1" src="https://www.paypal.com/en_US/i/scr/pixel.gif">
</form>

I have a drop downmenu which is populated from my database. I have to give each option_select and option_amount an entry after the list has been populated but it needs to link to the list. Is there a way I can give each option a bit of information that will be passed through to paypal because at the moment the only information being passed to the paypal cart is "PHOTOID & <?$ID?>" but I can't get it to send the Product that is selected! arrrghh!! Please help!
Here is my code:

<form target="_self" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="MYEMAILADDRESS" />
<input type="hidden" name="cancel_return" value="website/cancel">

<!-- Specify an Add to Cart button. -->
<input type="hidden" name="cmd" value="_cart" />

<input type="hidden" name="add" value="1" />
<!-- Specify details about the item that buyers will purchase. -->
<input type="hidden" name="item_name" value="PHOTOID<?php echo $pid;?> <?php echo $product;?>" />
<input type="hidden" name="currency_code" value="GBP" />


<!-- Provide a dropdown menu option field with prices. -->
<!--<input type="hidden" name="on1" value="Size" />-->

<select name="os1">
<option value="Delivery Destination">-- Select --</option>
<?php 
$i = 0;?>
<?php $prices=MYSQL_QUERY( "select * from FESTpricelist");

while($pricelist=mysql_fetch_array( $prices )) 

{
$id = "".$pricelist['id']."";
$product = "".$pricelist['product'].""; 
$price = "".$pricelist['price']."";
?>

<option value="<?php echo $product;?>"><?php echo $product;?> £<?php echo $price;?> </option>

<?php } ?>

</select>

<br />

<!-- Specify the price that PayPal uses for each option. -->
<input type="hidden" name="option_index" value="1" />
<?php 
$i = 0;?>
<?php $prices=MYSQL_QUERY( "select * from FESTpricelist");

while($pricelist=mysql_fetch_array( $prices )) 

{
$id = "".$pricelist['id']."";
$product = "".$pricelist['product'].""; 
$price = "".$pricelist['price']."";
?>

<input type="hidden" name="option_select<?php echo $i;?>" value="<?php echo $product;?>" />
<input type="hidden" name="option_amount<?php echo $i;?>" value="<?php echo $price; ?>" />
<?php $i = $i + 1;
} ?>

<!-- specify shipping cost -->
<input type="hidden" name="shipping1" value="0" />

<!-- Display the payment button. 
<input type="image" name="submit" border="0" src="https://www.paypal.com/en_US/i/btn/btn_cart_LG.gif" alt="PayPal - The safer, easier way to pay online" />-->
<input type="image" src="images/1301261203_edit_add.png" border="0" name="submit" alt="PayPal - The safer, easier way to pay online.">

<img alt="paypal" border="0" width="1" height="1" src="https://www.paypal.com/en_US/i/scr/pixel.gif">
</form>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓝天白云 2024-11-04 00:25:37

我明白了!!! :)

<script type="text/javascript">
function updateItemName() {
  var select = document.getElementById('select_stuff');
  var field = document.getElementById('item_name');

  field.value = select.options[select.selectedIndex].value;
};
</script>

<input type="hidden" name="item_name" id="item_name" value="" />

<select name="select_stuff" id="select_stuff" onchange="updateItemName()">
  <option value="Stuff 1" >Stuff 1</option>
  <option value="Stuff 2">Stuff 2</option>
</select>

I'VE GOT IT!!! :)

<script type="text/javascript">
function updateItemName() {
  var select = document.getElementById('select_stuff');
  var field = document.getElementById('item_name');

  field.value = select.options[select.selectedIndex].value;
};
</script>

<input type="hidden" name="item_name" id="item_name" value="" />

<select name="select_stuff" id="select_stuff" onchange="updateItemName()">
  <option value="Stuff 1" >Stuff 1</option>
  <option value="Stuff 2">Stuff 2</option>
</select>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文