Last verified: 10 Oct 2026. '
+ 'Bag yields per manufacturer specifications (Quikrete). '
+ 'Stairs formula verified against solid-step geometry. '
+ 'Concrete density taken as 150 lb/ft3 (2,400 kg/m3).
';
}
/* ============ 6. MODE DEFINITIONS ============
kind: 'len' (length), 'sm' (small: thickness/spacing), 'num' (plain number),
'yd3' (volume), 'usd' (price) */
var MODES = [
{ id:'slab', tab:'Slab', icon:'slab', title:'Concrete Slab Calculator',
formula:'Volume = Length x Width x Thickness / 27 (cubic yards)',
diagram: function(live){ return boxSVG(live); },
fields:[ {id:'l',label:'Length',kind:'len',ph:'10',defUnit:'ft'},
{id:'w',label:'Width',kind:'len',ph:'10',defUnit:'ft'},
{id:'d',label:'Thickness',kind:'sm',ph:'4',defUnit:'in',quick:[3,4,5,6]} ],
toImp: function(vals, units){ return {
l: toFt(vals.l, units.l), w: toFt(vals.w, units.w), d: toIn(vals.d, units.d) }; },
vol: function(v){ return CC.slabFt3(v.l, v.w, v.d); },
work: function(v, raw){
var L=+raw.l||0, W=+raw.w||0, T=+raw.d||0;
var f=v.l*v.w*(v.d/12);
return L+' x '+W+' x ('+T+' / 12) = '+fmt(f,1)+' ft3, then / 27 = '+fmt(f/27)+' yd3'; } },
{ id:'footing', tab:'Footing', icon:'footing', title:'Concrete Footing Calculator',
formula:'Volume = Length x Width x Depth / 27 (cubic yards)',
diagram: function(live){ return boxSVG(live); },
fields:[ {id:'l',label:'Length',kind:'len',ph:'20',defUnit:'ft'},
{id:'w',label:'Width',kind:'len',ph:'2',defUnit:'ft'},
{id:'d',label:'Depth',kind:'sm',ph:'12',defUnit:'in'} ],
toImp: function(vals, units){ return {
l: toFt(vals.l, units.l), w: toFt(vals.w, units.w), d: toIn(vals.d, units.d) }; },
vol: function(v){ return CC.rectFt3(v.l, v.w, v.d/12); },
work: function(v, raw){
var L=+raw.l||0, W=+raw.w||0, D=+raw.d||0;
var f=v.l*v.w*(v.d/12);
return L+' x '+W+' x ('+D+' / 12) = '+fmt(f,1)+' ft3, then / 27 = '+fmt(f/27)+' yd3'; } },
{ id:'wall', tab:'Wall', icon:'wall', title:'Concrete Wall Calculator',
formula:'Volume = Length x Height x Thickness / 27 (cubic yards)',
diagram: function(live){ return tallBoxSVG(live); },
fields:[ {id:'l',label:'Length',kind:'len',ph:'20',defUnit:'ft'},
{id:'h',label:'Height',kind:'len',ph:'8',defUnit:'ft'},
{id:'t',label:'Thickness',kind:'sm',ph:'8',defUnit:'in',quick:[6,8,10,12]} ],
toImp: function(vals, units){ return {
l: toFt(vals.l, units.l), h: toFt(vals.h, units.h), t: toIn(vals.t, units.t) }; },
vol: function(v){ return CC.wallFt3(v.l, v.h, v.t); },
work: function(v, raw){
var L=+raw.l||0, H=+raw.h||0, T=+raw.t||0;
var f=v.l*v.h*(v.t/12);
return L+' x '+H+' x ('+T+' / 12) = '+fmt(f,1)+' ft3, then / 27 = '+fmt(f/27)+' yd3'; } },
{ id:'column', tab:'Column', icon:'column', title:'Concrete Column / Pier Calculator',
formula:'Volume = pi x r squared x Height (cylinder)',
diagram: function(live){ return cylSVG(live); },
fields:[ {id:'d',label:'Diameter',kind:'sm',ph:'12',defUnit:'in'},
{id:'h',label:'Height',kind:'len',ph:'4',defUnit:'ft'},
{id:'n',label:'How many',kind:'num',ph:'1'} ],
toImp: function(vals, units){ return {
d: toIn(vals.d, units.d), h: toFt(vals.h, units.h), n: CC.num(vals.n)||1 }; },
vol: function(v){ return CC.cylFt3(v.d, v.h)*v.n; },
work: function(v, raw){
var D=+raw.d||0, H=+raw.h||0, N=Math.round(+raw.n)||1;
var r=(v.d/12)/2, f=Math.PI*r*r*v.h*N;
return 'pi x '+fmt(r,3)+' squared x '+H+' x '+N+' = '+fmt(f,2)+' ft3, then / 27 = '+fmt(f/27)+' yd3'; } },
{ id:'posthole', tab:'Post Holes', icon:'posthole', title:'Post Hole Concrete Calculator',
formula:'Each hole = pi x r squared x Depth. Great for fences and decks.',
diagram: function(live){ return cylSVG(live); },
fields:[ {id:'d',label:'Hole diameter',kind:'sm',ph:'10',defUnit:'in'},
{id:'h',label:'Hole depth',kind:'sm',ph:'36',defUnit:'in'},
{id:'n',label:'Number of holes',kind:'num',ph:'8'} ],
toImp: function(vals, units){ return {
d: toIn(vals.d, units.d), h: toIn(vals.h, units.h), n: CC.num(vals.n)||1 }; },
vol: function(v){ return CC.cylFt3(v.d, v.h/12)*v.n; },
work: function(v, raw){
var D=+raw.d||0, H=+raw.h||0, N=Math.round(+raw.n)||1;
var r=(v.d/12)/2, f=Math.PI*r*r*(v.h/12)*N;
return 'pi x '+fmt(r,3)+' squared x ('+H+' / 12) x '+N+' holes = '+fmt(f,2)+' ft3, then / 27 = '+fmt(f/27)+' yd3'; } },
{ id:'circle', tab:'Circle Slab', icon:'circle', title:'Circular Slab Calculator',
formula:'Volume = pi x r squared x Thickness / 27 (cubic yards)',
diagram: function(live){ return discSVG(live); },
fields:[ {id:'d',label:'Diameter',kind:'len',ph:'10',defUnit:'ft'},
{id:'t',label:'Thickness',kind:'sm',ph:'4',defUnit:'in',quick:[3,4,5,6]} ],
toImp: function(vals, units){ return {
d: toFt(vals.d, units.d), t: toIn(vals.t, units.t) }; },
vol: function(v){ return CC.circleSlabFt3(v.d, v.t); },
work: function(v, raw){
var D=+raw.d||0, T=+raw.t||0;
var r=v.d/2, f=Math.PI*r*r*(v.t/12);
return 'pi x '+fmt(r)+' squared x ('+T+' / 12) = '+fmt(f,1)+' ft3, then / 27 = '+fmt(f/27)+' yd3'; } },
{ id:'curb', tab:'Curb', icon:'curb', title:'Concrete Curb Calculator',
formula:'Volume = Length x Width x Height / 27 (cubic yards)',
diagram: function(live){ return boxSVG(live); },
fields:[ {id:'l',label:'Length',kind:'len',ph:'100',defUnit:'ft'},
{id:'w',label:'Width',kind:'sm',ph:'6',defUnit:'in'},
{id:'h',label:'Height',kind:'sm',ph:'6',defUnit:'in'} ],
toImp: function(vals, units){ return {
l: toFt(vals.l, units.l), w: toIn(vals.w, units.w), h: toIn(vals.h, units.h) }; },
vol: function(v){ return CC.curbFt3(v.l, v.w, v.h); },
work: function(v, raw){
var L=+raw.l||0, W=+raw.w||0, H=+raw.h||0;
var f=v.l*(v.w/12)*(v.h/12);
return L+' x ('+W+' / 12) x ('+H+' / 12) = '+fmt(f,1)+' ft3, then / 27 = '+fmt(f/27)+' yd3'; } },
{ id:'stairs', tab:'Stairs', icon:'stairs', title:'Concrete Stairs Calculator (Solid Steps)',
formula:'Solid steps = tread x riser x n(n+1)/2 x width',
diagram: function(live){ return stairsSVG(live); },
fields:[ {id:'s',label:'Steps',kind:'num',ph:'5'},
{id:'tr',label:'Tread depth',kind:'sm',ph:'11',defUnit:'in'},
{id:'ri',label:'Riser height',kind:'sm',ph:'7',defUnit:'in'},
{id:'w',label:'Width',kind:'len',ph:'4',defUnit:'ft'} ],
toImp: function(vals, units){ return {
s: CC.num(vals.s), tr: toIn(vals.tr, units.tr),
ri: toIn(vals.ri, units.ri), w: toFt(vals.w, units.w) }; },
vol: function(v){ return CC.stairsFt3(v.s, v.tr, v.ri, v.w); },
work: function(v, raw){
var S=Math.round(+raw.s)||0;
var f=(v.tr/12)*(v.ri/12)*(S*(S+1)/2)*v.w;
return 'Tread x riser x '+S+'x'+(S+1)+'/2 x width = '+fmt(f,1)+' ft3, then / 27 = '+fmt(f/27)+' yd3 (solid steps)'; } },
{ id:'bags', tab:'Bags', icon:'bags', title:'How Many Bags of Concrete?',
formula:'Bags = volume / bag yield (80 lb = 0.60 ft3, 60 lb = 0.45 ft3, 50 lb = 0.375 ft3, 40 lb = 0.30 ft3)',
diagram: function(live){ return bagSVG(live); },
custom:'bags', empty:'Enter the volume above.',
fields:[ {id:'y',label:'Concrete needed',kind:'yd3',ph:'1.25',defUnit:'yd3'} ] },
{ id:'mix', tab:'Mix Ratio', icon:'mix', title:'On-Site Mix Calculator (1:2:4)',
formula:'For site-mixed concrete: 1 part cement : 2 sand : 4 aggregate (by volume). Dry-volume factor 1.54.',
diagram: function(){ return mixSVG(); },
custom:'mix', empty:'Enter the volume above.',
fields:[ {id:'y',label:'Concrete needed',kind:'yd3',ph:'1',defUnit:'yd3'} ] },
{ id:'rebar', tab:'Rebar', icon:'rebar', title:'Rebar Calculator for Slabs',
formula:'Bars each way = ceil((dimension - 2 x cover) / spacing) + 1, with 3 in edge cover. Bar length = dimension - 2 x cover. Material estimate only, not structural design. Standard bar length 20 ft.',
diagram: function(live){ return rebarSVG(live); },
custom:'rebar', empty:'Enter slab size and spacing above.',
fields:[ {id:'l',label:'Slab length',kind:'len',ph:'20',defUnit:'ft'},
{id:'w',label:'Slab width',kind:'len',ph:'20',defUnit:'ft'},
{id:'s',label:'Bar spacing',kind:'sm',ph:'18',defUnit:'in'},
{id:'c',label:'Edge cover',kind:'sm',ph:'3',defUnit:'in'} ] },
{ id:'cost', tab:'Cost', icon:'cost', title:'Concrete Cost Estimator',
formula:'Cost = volume x price per unit.',
diagram: function(){ return costSVG(); },
custom:'cost', empty:'Enter volume and price above.',
fields:[ {id:'y',label:'Concrete needed',kind:'yd3',ph:'5',defUnit:'yd3'},
{id:'p',label:'Price per unit',kind:'usd',ph:'150'} ] }
];
/* Unit helpers for toImp */
function toFt(v, u){
v = parseFloat(v); if(!isFinite(v)) return 0;
u = u || 'ft';
return v * (TO_FT[u] || 1);
}
function toIn(v, u){
v = parseFloat(v); if(!isFinite(v)) return 0;
u = u || 'in';
return v * (TO_IN[u] || 1);
}
/* ============ 7. RENDERING ============ */
function fmt(v, d){
if(!isFinite(v)) return '0';
var s = v.toFixed(d===undefined?2:d);
if(s.indexOf('.')>=0) s = s.replace(/\.?0+$/,'');
return s;
}
/* Per-field unit selector HTML */
function unitSelectHTML(fieldId, kind, defUnit){
var opts = '';
var list = (kind==='len'||kind==='sm') ? FIELD_UNITS : (kind==='yd3' ? ['yd3','m3','ft3'] : []);
if(!list.length) return '';
list.forEach(function(u){
var sel = (u===defUnit) ? ' selected' : '';
opts += '';
});
return '';
}
function fieldHTML(f){
var isDim = (f.kind==='len'||f.kind==='sm'||f.kind==='yd3');
var sel = isDim ? unitSelectHTML(f.id, f.kind, f.defUnit||'ft') : '';
var suffix = '';
if(f.kind==='usd') suffix = ''+CUR+'';
var quick = '';
if(f.quick && f.quick.length){
quick = '
'+bagsWaste.b80+' x 80 lb'
+''+bagsWaste.b60+' x 60 lb'
+''+bagsWaste.b50+' x 50 lb'
+''+bagsWaste.b40+' x 40 lb'
+''+bagsWasteM.k25+' x 25 kg'
+''+bagsWasteM.k20+' x 20 kg
';
h += '
Working: '+mode.work(imp, vals)
+(waste>0 ? ' then x '+fmt(w,'3')+' for '+waste+'% waste' : '')+'
';
panel._summary = 'Bags for '+fmt(yd3b)+' cubic yards: '
+bb.b80+' x 80 lb, '+bb.b60+' x 60 lb, '+bb.b50+' x 50 lb, '+bb.b40+' x 40 lb. '
+'via concretequantity.com/concrete-calculator/#'+mode.id;
return h;
}
function calcMix(mode, panel, vals, units){
var u = units.y || 'yd3';
var yv = parseFloat(vals.y)||0;
var wetFt3 = (u==='m3') ? yv*35.3147 : (u==='ft3' ? yv : yv*27);
var mx = CC.mixForFt3(wetFt3);
var cb = Math.ceil(mx.cementFt3)||0;
var sY = mx.sandFt3/27, aY = mx.aggFt3/27;
var wg = cb*6; /* gallons, approx 6 gal per bag */
var h = '
Water: about half a bucket per bag, added gradually. Mix is suitable for non-structural work such as paths and bases. For structural concrete, use ready-mix to specification.
'
+ actionsHTML(mode.id)+'
';
panel._summary = 'Site mix (1:2:4) for '+fmt(wetFt3/27)+' cubic yards: '+cb
+' cement bags, '+fmt(sY)+' yd3 sand, '+fmt(aY)+' yd3 aggregate. '
+'via concretequantity.com/concrete-calculator/#'+mode.id;
return h;
}
function calcRebar(mode, panel, vals, units){
var l = toFt(vals.l, units.l||'ft');
var w = toFt(vals.w, units.w||'ft');
var s = toIn(vals.s, units.s||'in');
var c = vals.c ? toIn(vals.c, units.c||'in') : 3; /* default 3 in cover */
var rb = CC.rebarForSlab(l, w, s, c);
if(!(rb.totalLF>0)) return '
Enter slab size and spacing above.
';
var h = '
Rebar estimate
'
+'
'+fmt(rb.totalLF,0)+' linear feet
'
+'
'+rb.bars20+' x 20-ft bars'
+'Edge cover: '+fmt(c)+' in
'
+'
Working: '
+'Bars across width: ceil(('+fmt(w*12,0)+' - 2x'+fmt(c)+') / '+fmt(s)+') + 1 = '+rb.nW
+' bars x '+fmt(rb.barLenL,1)+' ft. '
+'Bars across length: ceil(('+fmt(l*12,0)+' - 2x'+fmt(c)+') / '+fmt(s)+') + 1 = '+rb.nL
+' bars x '+fmt(rb.barLenW,1)+' ft. '
+'Total = '+fmt(rb.totalLF,0)+' ft.
'
+'
Material estimate only, not structural design. '
+'Bars run the full slab length both ways with '+fmt(c)+' in edge cover. '
+'Laps are not counted, so add about 10% extra for laps and waste.
'
+ actionsHTML(mode.id)+'
';
panel._summary = 'Rebar estimate: '+fmt(rb.totalLF,0)+' linear feet ('+rb.bars20
+' x 20-ft bars, '+fmt(c)+' in cover). via concretequantity.com/concrete-calculator/#'+mode.id;
return h;
}
function calcCost(mode, panel, vals, units){
var u = units.y || 'yd3';
var yv = parseFloat(vals.y)||0;
var yd3v = (u==='m3') ? yv*1.30795 : (u==='ft3' ? yv/27 : yv);
var price = parseFloat(vals.p)||0;
var h = '
Cost estimate
';
var parts = [];
if(yd3v>0 && price>0){
var total = yd3v*price;
h += '
'+CUR+fmt(total)+'
';
h += ''+fmt(yd3v)+' yd3 x '+CUR+fmt(price)+' = '+CUR+fmt(total)+'';
parts.push(fmt(yd3v)+' yd3 x '+CUR+fmt(price)+' = '+CUR+fmt(total)+'');
panel._summary = 'Concrete cost: '+fmt(yd3v)+' cubic yards at '+CUR+fmt(price)+' = '+CUR+fmt(total)
+'. via concretequantity.com/concrete-calculator/#'+mode.id;
} else {
h += '
'+mode.empty+'
';
panel._summary = '';
}
h += '
';
if(parts.length) h += '
Working: '+parts.join(' ')+'
';
h += '
Material cost only. Delivery, short-load and pumping fees vary by supplier. Get a local quote for the full price.
';
h += actionsHTML(mode.id)+'
';
return h;
}
/* ============ 11. PANEL + TABS ============ */
function buildPanel(m, first){
var p = document.createElement('div');
p.className = 'cc-panel'+(first?' on':''); p.id = 'ccp-'+m.id;
p.setAttribute('role','tabpanel');
var inner = '