-5
I have this script but it doesn’t work:
<input type="radio" autocomplete="off" required value="Dinheiro e Cartão" name="pagamento" id="termos2"/> <span class="titulos_pgmnts">Dinheiro e Cartão</span><br>
<div id="termoTexto2">
<input type="text" id="soma1" value="<?php echo number_format($vtotal,2,",","."); // retorna: 270.78 ?>" name="">
<p></p>
<span class="titulos_pgmnts">Quanto em Dinheiro:</span> <input id="soma2" type="text" onKeyUp="mascaraMoeda(this, event)" autocomplete="off" autocomplete="off" value="" class="qtds_burgers" name="valortroco" placeholder="Digite o Valor" maxlength="6" onKeyPress="return(moeda(this,'.',',',event))"><p></p>
<p></p>
<span class="titulos_pgmnts">Restante no Cartão:</span> <input readonly id="result" type="text" autocomplete="off" autocomplete="off" class="qtds_burgers" name="valortroco" placeholder="0,00" maxlength="6" onKeyPress="return(moeda(this,'.',',',event))"><p></p>
<p></p>
</div>
<p></p>
<script>
//restantes entre cartão e dinheiro
jQuery(document).ready(function(){
jQuery('input').on('keyup',function(){
if(jQuery(this).attr('name') === 'result'){
return false;
}
var soma1 = (jQuery('#soma1').val() == '' ? 0 : jQuery('#soma1').val());
var soma2 = (jQuery('#soma2').val() == '' ? 0 : jQuery('#soma2').val());
var result = (parseInt(soma1) - parseInt(soma2));
jQuery('#result').val(result);
});
});
</script>
your question is not clear, put the full html and show what you want to do
– Ricardo Pontual
Ricardo edited there
– Felipe
It is returning me whole numbers I wanted to calculate with commas ex.: 22.50 - 20.00 = 2.50
– Felipe