JSFiddle - React, Tailwind, and code Playground

by Anik Islam Abhi

HTML

<form name="myform" onkeyup="calculate()">
  <label>Num of PAX :</label>
  <input type="text" name="qty" />
  <input type="hidden" name="cost" value="700" />
  <br/>
  <lable>Total Price: </lable>
  <input type="text" name="textbox" />

</form>

JavaScript

var form = document.forms.myform,
  qty = form.qty,
  cost = form.cost,
  output = form.textbox;

window.calculate = function() {
  var q = parseInt(qty.value, 10) || 0,
    c = parseFloat(cost.value) || 0;
  output.value = (q * c).toFixed(2);
};