webdevpuneet.com

Donation Amount Picker — Give Form HTML CSS JS

Donation Amount Picker · Forms · Plain HTML, CSS & JS · Live preview

CategoryForms

Copy & paste

Source Code

<form class="dap-card" id="dapForm">
  <h3>Support our work</h3>

  <div class="dap-freq" role="radiogroup" aria-label="Frequency">
    <button type="button" class="dap-freq-btn active" data-freq="once">One-time</button>
    <button type="button" class="dap-freq-btn" data-freq="monthly">Monthly</button>
  </div>

  <div class="dap-amounts" id="dapAmounts"></div>

  <div class="dap-custom" id="dapCustom">
    <span class="dap-currency">$</span>
    <input type="number" id="dapCustomInput" min="1" step="1" placeholder="Other amount">
  </div>

  <p class="dap-impact" id="dapImpact"></p>

  <button type="submit" class="dap-submit" id="dapSubmit">
    Donate <b id="dapTotal">$25</b> <span id="dapFreqLabel"></span>
  </button>
</form>

Extend with AI

Take This Snippet Further With AI

The AI prompt for this one is for Patreon supporters ($3 a month, 7 days free), along with a site with no ads. Supporters enter the passcode once and it is remembered in this browser.

· Become a supporter

What's included

Features

Preset amount tiles
Six configurable preset amounts anchor the gift size and give a fast, low-effort choice.
Mutually exclusive custom field
A custom flag keeps presets and the custom input from both appearing active — focusing custom deselects presets and vice versa.
One-time / monthly toggle
A prominent frequency switch makes recurring giving an equal, clearly-labeled option, reflected in the button.
Live impact messaging
Translates the dollar amount into concrete outcomes, keyed to the nearest tier, updating instantly for any amount.
Validation and gated submit
The donate button disables for empty or sub-$1 amounts so a meaningless gift can never be submitted.
Accurate button total
The donate button always shows the exact amount and frequency ("Donate $50 / month") at the point of action.
Single sync() source of truth
One function keeps active states, total, frequency label, impact, and the gate consistent with the selection.
Brand-adaptable
Configurable presets, impact copy, and a single accent color make it fit any cause.

About this UI Snippet

Donation Amount Picker — Preset + Custom Amounts with Impact Messaging

Screenshot of the Donation Amount Picker snippet rendered live

The amount-selection step is where most donation forms succeed or fail. Ask for a freeform number and people freeze or give the minimum; offer well-chosen presets with a clear custom option and a sense of impact, and average gifts rise. This snippet builds a conversion-focused donation picker in plain HTML, CSS, and vanilla JavaScript: preset amount tiles, a custom-amount field, a one-time/monthly toggle, and a live "here's what your gift does" impact message.

Presets anchor the decision

Six preset tiles ($10 through $500) give donors a fast, low-effort choice and quietly anchor expectations — seeing $50 and $100 as options nudges the typical gift upward versus a blank field where many default to the smallest round number they can justify. Selecting a preset highlights it in green and updates the donate button's total. The presets are a simple array, so you tune them to your audience: the right ladder for a small grassroots cause differs from a major nonprofit.

A custom field that doesn't fight the presets

Donors who want to give a specific amount need an obvious path, but the custom field and the presets must stay mutually exclusive — selecting a preset clears the custom input, and typing (or focusing) the custom field deselects every preset. This custom flag is the detail that prevents the confusing state where both a preset and a custom number look active. Focusing the custom field immediately treats it as the active amount, so there's no extra click.

One-time vs. monthly, framed clearly

A frequency toggle switches between a one-time gift and a recurring monthly donation — and recurring donors are dramatically more valuable to a nonprofit over time, so making monthly a prominent, equal option (not a buried checkbox) matters. The donate button reflects the choice exactly: "Donate $25" or "Donate $25 / month", so the commitment is never ambiguous at the point of action.

Impact messaging that makes the gift tangible

Below the amount, a live message translates the dollar figure into concrete impact ("Supplies school materials for a child for a month"), keyed to the nearest preset at or below the chosen amount. Connecting money to outcome is one of the most reliable ways to increase giving — "$50" is abstract, but "a day of meals for a family of four" is a decision someone can feel good about. The message updates instantly as the amount changes, including for custom values, which fall to the appropriate tier's message.

Validation and submission

The donate button disables for an empty or sub-$1 custom amount, and the impact line prompts the donor to enter a value — so the form never lets someone submit a meaningless gift. On submit you proceed to payment with the { amount, freq } pair; the demo shows a thank-you confirmation, but in production this is where you'd hand off to Stripe, PayPal, or your payment processor. Because the amount and frequency are plain state, wiring that handoff is trivial.

Accessible and adaptable

The frequency control is a role="radiogroup", amounts are real buttons, and the whole form is driven by one sync() function that keeps every visual — active states, total, frequency label, impact, and the submit gate — consistent with the current selection. Re-theme the green to your brand and adjust the presets and impact copy, and it fits any cause.

Step by step

How to Use

  1. 1
    Paste HTML, CSS, and JSA donation form renders with a one-time/monthly toggle, six preset amounts ($25 pre-selected), a custom field, and an impact message.
  2. 2
    Pick a presetClick an amount tile — it highlights green, the donate button total updates, and the impact message reflects the gift.
  3. 3
    Enter a custom amountType in the "Other amount" field — every preset deselects, and the total, impact, and validation update live.
  4. 4
    Switch frequencyToggle Monthly — the donate button shows "/ month" so the recurring commitment is explicit.
  5. 5
    Tune the presets and impactEdit the PRESETS array and the IMPACT messages to fit your cause and donor base.
  6. 6
    Connect a payment processorOn submit, hand off { amount, freq } to Stripe, PayPal, or your processor instead of the demo confirmation.

Real-world uses

Common Use Cases

Nonprofit donation pages
The core give form for charities and fundraising campaigns, with impact framing that lifts average gifts.
Creator and membership support
Let supporters pick a one-time or monthly contribution — pair with a waitlist signup or community flow.
Crowdfunding and campaigns
Offer reward tiers as preset amounts with what each unlocks as the impact message.
Tip jars and pay-what-you-want
Adapt the presets and copy for optional tipping on free or open-source products.
Event and gala fundraising
Collect pledges with suggested amounts tied to specific outcomes, confirming each gift with an animated success checkmark.
Learning preset + custom input patterns
A reference for mutually-exclusive preset/custom selection and live derived messaging — compare with a tip calculator for the percentage variant.
Related: Form Change Diff Preview — Show Exactly What Will Change Before Saving
See the Form Change Diff Preview — Show Exactly What Will Change Before Saving for a related forms pattern worth pairing with this one.

Got questions?

Frequently Asked Questions

On submit, take the { amount, freq } and hand off to your processor: for Stripe, create a Checkout Session (one-time mode for "once", subscription mode for "monthly") and redirect, or use Payment Elements for an embedded flow; for PayPal, use their Donate SDK with the amount. Keep the selection in your form state and pass it to the processor's amount and recurrence parameters.

Tune the PRESETS array to your audience and historical average gift — a common approach places your current average in the middle of the ladder so it's a comfortable, anchored choice, with higher options that gently raise expectations. Test different ladders; the right presets for a grassroots cause differ from a large nonprofit. Avoid too many options (six is plenty) to prevent choice paralysis.

Connecting a dollar figure to a concrete outcome ("a day of meals for a family of four") makes an abstract number feel meaningful and consistently increases giving. Keying the message to the nearest preset at or below the chosen amount means even custom values get a relevant, motivating message rather than a blank space.

Track a "custom" boolean: clicking a preset sets it false (and clears the custom input), while focusing or typing in the custom field sets it true (and deselects all presets). Drive the active highlight and the effective amount from that flag, so exactly one of the two is ever active — this prevents the confusing state where both a preset and a custom number appear selected.

In React, hold amount, freq, and custom in useState and derive the total, impact, and validity with useMemo; in Vue, use ref()/computed(); in Angular, use component fields with getters. The impactFor() lookup and the preset/custom exclusivity logic are plain functions that port unchanged — only the per-interaction re-render moves into the framework.