JSFiddle - React, Tailwind, and code Playground
HTML
<form id="quantityform" method="post" action="#">
<input type="hidden" name="setcost" value="50" />
<label for="currentcost">Total cost: </label><input type="text" id="currentcost" name="currentcost" value="" />
<label for="quantity">Quantity: </label><input type="text" value="" id="quantity" name="quantity" placeholder="How many items would you like?" />
<input type="submit" value="Place order" />
</form>
JavaScript
$(function() {
$("[name=quantity]").blur(function() {
var setval = $("[name=setcost]").val();
var quantity = $("[name=quantity]").val();
var total = setval*quantity;
$("[name=currentcost]").val(total);
});
})