I need a function to determine: (1) if two inputs have values, throw an error. (2) if neither input has value, throw an error. (3) if input B or input D has a value, determine which Calculate function to then use. Both Calculate functions work, when called as
onClick="Calculate(this.form.input_A.value, this.form.input_B.value, this.form.input_C.value, this.form)"
onClick="Calculate2(this.form.input_A.value, this.form.input_C.value, this.form.input_D.value, this.form)"
But when I use to call the function below:
onclick="compute();"
The errors work, but I'm not calling the Calculate functions right, I'm sure its something obvious but I can't see it. The answer is no longer getting displayed, as it was before the error function was added.
<SCRIPT LANGUAGE="JavaScript">
function compute() {
var B = document.getElementById("input_B").value;
var D = document.getElementById("input_D").value;
if (B != "" && D != "") {
alert("You may only enter Assessment or Annual Property Taxes.");
} else if (B != "") {
Calculate(B);
} else if (D != "") {
Calculate2(D);
} else {
alert("You must enter a value into either Assessment or Annual Property Taxes.");
}
}
function Calculate(Atext, Btext, Ctext, form) {
var A = parseFloat(Atext);
var B = parseFloat(Btext);
var C = parseFloat(Ctext);
form.Answer.value = ((B - A) * C) / 1000;
}
function Calculate2(Atext, Ctext, Dtext, form) {
var A = parseFloat(Atext);
var C = parseFloat(Ctext);
var D = parseFloat(Dtext);
form.Answer.value = D - ((A * C) / 1000);
}
function ClearForm(form) {
form.input_A.value = "";
form.input_B.value = "";
form.input_C.value = "";
form.input_D.value = "";
form.Answer.value = "";
}
</SCRIPT>
CalculateandCalculate2than just "D" and "B"?