Code:
<html>
<head>
<script type="text/javascript">
function CoffeeBlend() {
var EspressoPercent = parseFloat(document.form1.first.value)||0;
var SumatraPercent = parseFloat(document.form1.second.value)||0;
if (EspressoPercent + SumatraPercent == 100)
{
FinalPrice = (((EspressoPercent * 5.99) + (SumatraPercent * 8.99)) / 100);
document.form1.answer.value == FinalPrice;
}
else
{
alert("Your percentages must sum to 100. \n Click OK to contine.")
}
</script>
</head>
<body>
<i><small>Please note that the sum of the percentages below must equal 100.</small></i>
<form name="form1">
<table align="left">
<tr>
<td>
Percent Espresso in the blend: <input type="text" size="2" name="first">%
//text and text box for the Espresso percentage
<br>
Percent Sumatra in the blend: <input type="text" size="2" name="second">%
//text and text box for the Sumatra percentage
<br>
Final Price: $<input type="text" readonly="readonly" size="4" name="answer">
//text box for the blend's final price
<br>
<input type="button" value="Find Price" onclick="CoffeeBlend()">
//button that generates the final price
<input type="reset" class="gain" value="Clear Fields">
//an extra button that clears the text boxes
</td>
</tr>
</table>
</form>
</body>
</html>
There is one logical mistake in your above script which I've noted in red color and you must use single equal (=) while you assign a value as the following line
Code:
document.form1.answer.value = FinalPrice;
== used for comparison purposes not for assignment purposes.
Bookmarks