Jump to content

Update Paypal value from a selection list with PHP


toyfruit

Recommended Posts

Hi All

I have a selection box which contains a list of items and values. The list is populated from a database table:

 

$dropdown = mysql_query("SELECT * FROM cost", $connection);
echo "<select name='dropdown'>";
while ($ddrow = mysql_fetch_array($dropdown)){		
  	echo "<option>" . $ddrow['cost_desc'] . " - £" . $ddrow['cost_price'] . "</option>";		
}
echo "</select>";	

 

I want to be able to change the 'amount' value in a paypal 'add to cart' button based on what the new selected item is in the dropdown list (preferably on something like an 'onchange' event or something).

 

My paypal 'add to cart' button would look like this (with the variable $my_new_value changing depending on what I had selected in the drop down box):

 

<form method="post" action="https://www.paypal.com/cgi-bin/webscr">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="add" value="1">
<input type="hidden" name="business" value="[email protected]">
<input type="hidden" name="item_name" value="My Item">
<input type="hidden" name="item_number" value="123">
<input type="hidden" name="amount" value="<?php echo $my_new_value ?>">
<input type="hidden" name="shipping" value="1.00">
<input type="hidden" name="shipping2" value="0.50">
<input type="hidden" name="handling" value="2.00 ">
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="return" value="http://www.yoursite.com/thankyou.htm">
<input type="hidden" name="undefined_quantity" value="1">
<input type="image" src="http://images.paypal.com/en_US/i/btn/x-click-but22.gif" border="0" name="submit" width="87" height="23" alt="Make payments with PayPal - it's fast, free and secure!">
</form>

 

Can anyone explain how I could do this?

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.