toyfruit Posted September 10, 2008 Share Posted September 10, 2008 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? Link to comment https://forums.phpfreaks.com/topic/123638-update-paypal-value-from-a-selection-list-with-php/ Share on other sites More sharing options...
toyfruit Posted September 11, 2008 Author Share Posted September 11, 2008 Just wondered if anyone could help me quickly with this. I just need to be able to update a variable when the selected item changes Link to comment https://forums.phpfreaks.com/topic/123638-update-paypal-value-from-a-selection-list-with-php/#findComment-638914 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.