JSFiddle - React, Tailwind, and code Playground
HTML
<form>
<input id="quantity" class="qty" type="text" placeholder="quantity" />
<input type="button" value="calculate" onclick = "update();" />
</form>
<!--display total cost here-->
<span id="ans">The Cost is: totalcost</span>
JavaScript
var cost = 25;
function update() {
var cost = 25;
var quantity = document.getElementById("quantity").value;
var totalcost = (cost * parseInt(quantity));
document.getElementById("ans").innerHTML = "The Cost is:" + totalcost;
// send total back to html document and display as total cost
}