Hi to all forum members ,

I'm building a site for an air freight company and wondered if anyone out there has some html code for a freight calculator. The 5 fields i need are

KG
Length
Heigtht
Width
Destination Airport

I need to be able to enter predefined values dependant on the destination airport.

Any help would be very welcomed !!!!

Dani AI

Generated

A concise implementation plan and practical tips for the air‑freight calculator thread started by (and following 's point that HTML alone cannot do math).

Start with a tiny form using input type="number" for numeric fields and a select for destination. Keep per‑destination tariffs (per‑kg, per‑m3, fixed fees, currency, rounding rules) in a JSON file or a small API so rates can be updated without changing page code; retrieve them with the Fetch API. Validate on both client and server (never trust client input): check units, non‑negative numbers, sensible maxima, and apply carriers' rounding rules before presenting totals.

Compute both the mass and the volumetric options and pick the higher. Include an adjustable dimensional divisor (carriers often differ), and be explicit about units (cm vs m, kg). Example calculation in JavaScript (core idea — adapt to your app and rounding rules):

function calculateTotal({weightKg, l_cm, w_cm, h_cm, dest, tariffs, divisor=6000}) {
  const t = tariffs[dest];
  if (!t) throw new Error('Unknown destination');
  const volumeM3 = (l_cm * w_cm * h_cm) / 1e6;
  const weightCost = weightKg * t.perKg + t.fixedFee;
  const volumeCost = volumeM3 * t.perM3 + t.fixedFee;
  const dimWeightKg = (l_cm * w_cm * h_cm) / divisor;
  const dimCost = dimWeightKg * t.perKg + t.fixedFee;
  const total = Math.max(weightCost, volumeCost, dimCost);
  return new Intl.NumberFormat(t.locale || 'en-US', {style:'currency', currency: t.currency}).format(total);
}

Final tips: use step and min attributes to help input, show units next to fields, round according to carrier policy (round up to next kg or 0.1 m3 if required), and test edge cases (zero, very small, very large). For reference on input controls, formatting and dimensional weight concepts see input type=number, Intl.NumberFormat and the dimensional weight overview (Dimensional weight).

Recommended Answers

All 2 Replies

HTML can't do math. You'll have to use JavaScript or something server side. What's the formula for the calculation?

Thanks for the answer , the formula would be something like

Freight total =
KGs x Seleted Destination tariff per kg + Fixed amount for taxes etc.

Or

Volume x Selected Destination tarrif per m3 + Fixed amount for tax etc.

Whichever is greater

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.