Is It Possible?! To Give a paypal dynamic drop down menu item a dynamic name
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 $pr开发者_JAVA技巧oduct;?>"><?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'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>
精彩评论