<!DOCTYPE html>
<html lang="el">
<head>
<form id="purchase"">
<table border=1>
<thead>
<tr>
<th>Menu</th>
<th>Price</th>
<th>Quantity</th>
</tr>
</thead>
<tbody>
<tr>
<td>Coffee</td>
<td id="coffeePrice" value="2.99">$2.99</td>
<td><input type="number"
name="quantityCoffee"
id="quantityCoffee"
></td>
</tr>
<tr>
<td>Tea</td>
<td id="teaPrice" value="1.99">$1.99 </td>
<td><input type="number"
name="quantityTea"
id="quantityTea"
></td>
</tr>
<tr>
<td>Water</td>
<td id="waterPrice" value="1.25">$1.25</td>
<td><input type="number"
name="quantityWater"
id="quantityWater"
></td>
</tr>
</tbody>
</table>
<input type="submit"
name="totalCost"
value="Total Cost"
onclick= "totalCost();">
<textarea id="display"></textarea>
</form>
<SCRIPT TYPE="text/javascript">;
<--
function totalCost()
{
var qC= document.getElementById("quantityCoffee");
var qT= document.getElementById("quantityTea");
var qW= document.getElementById("quantityWater");
var sum= (qC * 2.99) + (qT * 1.99) + (qW * 1.25);
document.getElementById("display").innerHTML = sum;
}
function test()
{
document.getElementById("display").innerHTML = "Cost is ";
}
// -->;
</SCRIPT>
</head>
</html>
Hello guys, so i am trying to use a form to make a ordering menu. This is the code that i have so far. The trouble i am having is that the javascript won't return to total cost after it calculates it back into the text area once the button is clicked. What am i doing wrong?