Hi-- I'm writing a Java Script calculator for winemakers that will calculate required additions to the grape juice based upon the quantity of juice entered, the current amount of a chemical called SO2 and the desired amount of SO2. The problem I'm having is with the quantities-- I'm trying to write this such that it'll work with either gallons or liters. In the quantity function, I'm able to convert from one to the other, i.e. if gallons are blank it's calculated from the liters entered and vice versa. But the other functions, validate and calculate seem to ignore the caluculated values. I program was originally writtedn for gallons only and if the liters pieces are stripped out, everything works. It's as if the other functions run before the calculations can occur. Below is the whole of the code, inclusive of the form. Any help would be greatly appreciated-- I've run out of ideas. Thanks in advance.

if (gallons == "")
window.alert("Please enter the quantity of must, juice or wine");
if (liters == "")
window.alert("Please enter the quanitity of must, juice or wine");
if (currentso2 == "")
window.alert("Please enter the current sulfite level in the must, juice or wine");
if (desiredso2 == "")
window.alert("Please enter the desired sulfite level in the must, juice or wine");

if (desiredso2 < 50)
window.alert("To mimimize the chance of spoilage and oxidation, at least 50ppm of Sulfur Dioxide is recommended");
if (desiredso2 > 150)
window.alert("Sulfur Dioxide levels greater than 150ppm can impact the taste of your finished wine and lead to adverse reactions in some people");
if (currentso2 > desiredso2)
window.alert("Your current free sulfite level you entered is greater than the desired sulfite level you entered. If this is correct, you do not need to add any additional sulfite");
calculate(results)
}

Additionally, it would be to your benifit to read the forum posting guidelines, particularly those regarding using bbCode
...CODE HERE... when posting code... That is an awful lot of code for someone to cut from your post and this may very well be the reason noone has responded... But still, a lack of response is not a reason to double post...

<p id="results">
To achieve your desired level of free sulfites, the recommended amount of potassium metabisulfite to be added to your must, juice or wine is <em><span id="grams"> </span> grams</em> which is approximately <em><span id="tspoons"> </span> teaspoons</em>.
Alternatively, the addition of <em><span id="campden"> </span> Campden tablets</em> will also bring your must, juice or wine to the free sulfite level you specified.
</p>

case (desired > 150):
window.alert("Sulfur Dioxide levels greater than 150ppm can impact the taste of your finished wine and lead to adverse reactions in some people");
return;

case (current > desired):
window.alert("Your current free sulfite level you entered is greater than the desired sulfite level you entered. If this is correct, you do not need to add any additional sulfite");
return;
}