I have this PayPal button set up . I wanted to have a drop down for amount and a second one for quantity.
I used the PayPal button maker to create the drop downs but the amount and quantity did not carry over-every time I tested it the amount in the cart default to the lowest price-$25 and the quantity doesn't carry over either.

I would like help making a drop down for both amount and quantity where both values carry over to PayPal.

<form action="" method="post">
    <input type="hidden" name="cmd" value="_s-xclick" /> <input type="hidden" name="hosted_button_id" value="3665970" />
    <table cellspacing="2" cellpadding="2" width="250">
    </table>
    <table cellspacing="4" cellpadding="4" class="centeredtable">
        <tbody>
            <tr>
                <td><input type="hidden" name="on0" value="Card Value" /><span style="color: rgb(255, 227, 132);"><strong>Card Value</strong></span></td>
            </tr>
            <tr>
                <td><select name="os0">
                <option value="Amount">Amount $20.00    </option>
                <option value="Amount">Amount $25.00    </option>
                <option value="Amount">Amount $50.00    </option>
                <option value="Amount">Amount $75.00    </option>
                <option value="Amount">Amount $100.00   </option>
                <option value="Amount">Amount $150.00   </option>
                <option value="Amount">Amount $200.00   </option>
                <option value="Amount">Amount $300.00   </option>
                <option value="Amount">Amount $400.00   </option>
                <option value="Amount">Amount $500.00 </option>
                </select></td>
            </tr>
            <tr>
                <td><input type="hidden" name="on1" value="Quantity" /><span style="color: rgb(255, 227, 132);"><strong>Quantity                 </strong></span></td>
            </tr>
            <tr>
                <td><select name="os1">
                <option value="1">1     </option>
                <option value="2">2     </option>
                <option value="3">3     </option>
                <option value="3">3     </option>
                <option value="5">5     </option>
                <option value="6">6     </option>
                <option value="7">7     </option>
                <option value="8">8     </option>
                <option value="9">9     </option>
                <option value="10">10  </option>
                </select></td>
            </tr>
            <tr>
                <td><input type="hidden" name="on2" value="Occasion (if any)" /><strong><span style="color: rgb(255, 227, 132);">Occasion (if any)</span></strong></td>
            </tr>
            <tr>
                <td><input type="text" name="os2" maxlength="60" /></td>
            </tr>
        </tbody>
    </table>
    <p style="text-align: center;"><input type="hidden" name="currency_code" value="USD" /> <input type="image" border="0" src="https://www.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" class="aligncenter" name="submit" alt="PayPal - The safer, easier way to pay online!" /> <img height="1" border="0" width="1" alt="" /></p>
</form>

Dani AI

Generated

was right to switch away from a saved/hosted button — PayPal will use the values stored with a hosted button (hosted_button_id/_s-xclick) and ignore most client-side price/quantity changes. For a classic “Buy Now / Add to Cart” where a dropdown selects a priced option and a separate dropdown supplies quantity, use a non-hosted (clear-text) button and the priced-option variables PayPal expects. (docplayer.net)

A minimal example (priced first dropdown, explicit quantity):

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
  <input type="hidden" name="cmd" value="_xclick">
  <input type="hidden" name="business" value="seller@example.com">
  <input type="hidden" name="item_name" value="Gift Card">
  <input type="hidden" name="currency_code" value="USD">

  <input type="hidden" name="on0" value="Card Value">
  <select name="os0">
    <option value="20">Card $20.00</option>
    <option value="25">Card $25.00</option>
    <option value="50">Card $50.00</option>
  </select>

  <input type="hidden" name="option_index" value="0">
  <input type="hidden" name="option_select0" value="20">
  <input type="hidden" name="option_amount0" value="20.00">
  <input type="hidden" name="option_select1" value="25">
  <input type="hidden" name="option_amount1" value="25.00">
  <input type="hidden" name="option_select2" value="50">
  <input type="hidden" name="option_amount2" value="50.00">

  Quantity:
  <select name="quantity">
    <option value="1">1</option><option value="2">2</option><option value="3">3</option>
  </select>

  <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" name="submit" alt="PayPal">
</form>

Notes and gotchas: option_selectN values must match the <option> value exactly; set option_index to the onN index that contains the priced options; to pass quantity, name the field quantity (not os1). See PayPal’s option-variable examples. (docplayer.net)

— subscription buttons are different: classic Subscribe option fields are not intended to change the recurring amount; the integration guide advises against using option fields to vary subscription price. To offer selectable monthly plans, create separate subscribe buttons (one per plan) or move to PayPal’s Subscriptions/Billing Plans APIs (server-side plan creation + JS SDK) for a programmatic, secure solution. (docplayer.net)

Security: clear-text buttons are editable by attackers — always verify final transaction details server-side (IPN or webhooks) before delivering goods or enabling services. Use PayPal’s IPN/webhook flow to confirm amounts and transaction authenticity. (developer.paypal.com)

References: PayPal option fields (Help) (https://www.paypal.com/is/cshelp/article/how-do-i-add-user-selection-options-to-my-paypal-button-ts1182), Integration Guide (priced options) (https://docplayer.net/5170138-Paypal-payments-standard-integration-guide.html), Subscriptions API (https://developer.paypal.com/docs/multiparty/subscriptions/integrate/), IPN (https://developer.paypal.com/api/nvp-soap/ipn/IPNIntro/).

I solved the problem. The answer was using a non-hosted clear text version of the code, removing the "Remove Code Protection".line. Hosted means that specific variables are stored on the PayPal Servers which in turn makes these variables tamper proof. Then the basic adjustments "took" and the drop downs work perfectly.

It's not clear what you actually removed from the code shown?

I want a similar, though simpler, button to allow different monthly subscription choices & have the same problem that no matter what choice is made the amount in PayPal defaults to the lowest rate, (although the description will be correct).

Can you please clarify what changes you made to the code to make it work?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.