There are some spellings mismatch in your code, for example-
In the HTML file, you have given id, "ktichen" and trying to access "kitchen"
var kitchen = Number(document.getElementById("ktichen").value);
In the HTML file, you have given id "AC" and trying to access "ac"
var qac = (document.getElementById("ac"));
In the HTML file, you have given "Yes" and trying to match with "yes", so here either use the accurate value to match or convert bot sides of equal in lower case.
if (qbst === "Yes") { // }
I have modified the code, and run it, it is working now without any errors, I did not check the calculation, you can verify it.
Try with replacing the code by below-
function cal() {
var story = Number(document.getElementById("story").value);
var width = Number(document.getElementById("width").value);
var length = Number(document.getElementById("length").value);
var kitchen = Number(document.getElementById("ktichen").value);
var bathroom = Number(document.getElementById("bathroom").value);
var qgut = (document.getElementById("gut"));
var qbst = (document.getElementById("bst").value);
var qoil = (document.getElementById("oil"));
var qheat = (document.getElementById("heat"));
var qac = (document.getElementById("AC"));
var qbrick = (document.getElementById("brick"));
var totalsqft;
var electricalcostlow;
var electricalcosthigh;
var pipingcostlow;
var pipingcosthigh;
var oilcostlow;
var oilcosthigh;
var heatingcostlow;
var heatingcosthigh;
var accostlow;
var accosthigh;
var generallow;
var generalhigh;
var bricklow;
var brickhigh;
var kitchencostlow = kitchen * 1;
var kitchencosthigh = kitchen * 2;
var bathroomcostlow = bathroom * 1;
var bathroomcosthigh = bathroom * 2;
var estlow;
var esthigh;
if (qbst === "Yes") {
totalsqft = (story + 1) * (width * length)
} else {
totalsqft = (story) * (width * length)
}
if (qgut === "Yes") {
electricalcostlow = totalsqft * 1
} else {
electricalcostlow = totalsqft * 2
}
if (qgut === "Yes") {
electricalcosthigh = totalsqft * 1
} else {
electricalcosthigh = totalsqft * 2
}
if (qgut === "Yes") {
pipingcostlow = totalsqft * 1
} else {
pipingcostlow = totalsqft * 2
}
if (qgut === "Yes") {
pipingcosthigh = totalsqft * 1
} else {
pipingcosthigh = totalsqft * 2
}
if (qoil === "Yes") {
oilcostlow = 1;
oilcosthigh = 2
} else {
oilcostlow = 0;
oilcosthigh = 0
}
if (qheat === "Yes") {
heatingcostlow = story * 1;
heatingcosthigh = story * 2
} else {
heatingcostlow = 0;
heatingcosthigh = 0
}
if (qac === "Yes") {
accostlow = story * 1;
heatingcosthigh = story * 2
} else {
accostlow = 0;
accosthigh = 0
}
if (qgut === "Yes") {
generallow = totalsqft * 2
} else {
generallow = totalsqft * 1
}
if (qgut === "Yes") {
generalhigh = totalsqft * 2
} else {
generalhigh = totalsqft * 1
}
if (qbrick === "Yes") {
bricklow = ((width * length) * 1) * 2
} else {
generallow = 0
}
if (qbrick === "Yes") {
brickhigh = ((width * length) * 1) * 2
} else {
brickhigh = 0
}
estlow = bricklow + generallow + accostlow + heatingcostlow + oilcostlow + pipingcostlow + electricalcostlow + kitchencostlow + bathroomcostlow;
esthigh = brickhigh + generalhigh + accosthigh + heatingcosthigh + oilcosthigh + pipingcosthigh + electricalcosthigh + kitchencosthigh + bathroomcosthigh;
document.getElementById("estlow").innerHTML = length * width;
document.getElementById("esthigh").innerHTML = width * length;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div>
<h1>Property Rehab Estimator - Enter details below</h1>
<form>
<h3>
Answer questions:
</h3>
Is this a full gut?
<select id="gut">
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
<br/>
Is this there a basement?
<select id="bst">
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
<br/>
Is there an oil tank that needs to be removed?
<select id="oil">
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
<br/>
Does it need a new heating system?
<select id="heat">
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
<br/>
Does it need a new A/C system?
<select id="AC">
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
<br/>
Does it need masonry work?
<select id="brick">
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
<br/>
<h3>
Enter property dimensions:
</h3>
Total # of stories with attic (not including basement) <input type="numbers" id="story" placeholder="story" />
<br />
Building Width <input type="numbers" id="width" placeholder="width" />
<br />
Building Length <input type="numbers" id="length" placeholder="length" />
<br />
Total # of kitchens (include ones you want to add during rehab) <input type="numbers" id="ktichen" placeholder="# of kitchen" />
<br />
Total # of bathroom (include ones you want to add during rehab) <input type="numbers" id="bathroom" placeholder="# of bathroom" />
<br />
<br/>
<br/>
<input id="est" type="button" value="Estimate" onclick="cal()" />
<input id="reset" type="reset" value="Reset" />
</form>
<h1 id="estlow"> Low Estimate = </h1>
<h1 id="esthigh"> High Estimate = </h1>
</div>
</body>
</html>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…