Im using js to calculate in real time the cost, but when i click on save, the value on the database is 0 even when the value changed on the input field.
function calculate(){
try{ var num1 = parseInt(document.getElementById('a').value) || 0;
var num2 = 255;
document.getElementById('price').value = num1 * num2;}
catch(e){}
}
Heres the HTML code:
<div class="form-group">
<p>Number</p>
<input type="number" id ="a" name="persons" [(ngModel)]="reserv.persons" rows="2" class="form-control" oninput="calculate();">
</div>
<div class="form-group">
<p>Price</p>
<input name="price" type="number" id="price" [(ngModel)]="reserv.price" oninput="calculate();" class="form-control">
</div>