JSFiddle - React, Tailwind, and code Playground
by Divy Shah
HTML
Sale Price: <span id="saleprice">1000</span> <!-- Printed from PHP(Database) -->
<br>
Quantity: <input type="number" id="quant" placeholder="2" onblur="myFunction(this.value)" />
<br>
Shipment Charge: <select name="shipment" id="shipmentSelect">
<option value="100"> 100 per 1 item </option>
<option value="150"> 150 per 2 item </option>
</select>
<br>
Total Price: <input id="total" readonly />
JavaScript
function myFunction(quantInput)
{
var salePrice = document.getElementById("saleprice");
var quantity = document.getElementById("quant");
var shipment = document.getElementById("shipmentSelect");
var total = document.getElementById("total");
shipment.selectedIndex = quantInput - 1;
var shipmentValue = shipment.value;
salePrice = salePrice.innerHTML;
var totalPrice = (salePrice*quantInput) + parseInt(shipmentValue);
total.value = totalPrice;
}