1
I have an input that is required with currency Mask but the user can enter 2 more inputs. I am not able to do this calculation, especially when the 3 inputs of values are not used.
Value input only appears if the user selects something in select.
Follow the codes:
<div class="col-sm-4">
<div class="row control-group">
<div class="form-group col-xs-12 controls">
<label>Cirurgia 1<span>*</span></label>
<select class="form-control selectpicker" id="cirurgia" required data-validation-required-message="Escolha a cirurgia." multiple title="Selecione a Cirurgia">
<optgroup data-max-options="1">
<option>Abdominoplastia </option>
<option>Blefaroplastia </option>
<option>Dermolipectomia </option>
<option>Implante Capilar </option>
<option>Lipoaspiração </option>
<option>Lipoescultura </option>
<option>Lifting </option>
<option>Mastopexia </option>
<option>Mamoplastia de Aumento </option>
<option>Mamoplastia Redutora </option>
<option>Rinoplastia </option>
<option>Rinoseptoplastia </option>
<option>Outros </option>
</optgroup>
</select>
<p class="help-block"></p>
</div>
</div>
<div class="row control-group valorc1">
<div class="form-group col-xs-12 controls">
<label id="namec1"><span>*</span></label>
<input type="text" class="form-control valor" id="valorc1" name="data[valorc1]" required data-validation-required-message="Digite o valor." autocomplete="off">
<p class="help-block"></p>
</div>
</div>
This code repeats more 2x obviously changing the ids to 2 and 3.
Below the result where the calculation should appear:
<div class="col-sm-4">
<div class="row control-group">
<div class="form-group col-xs-12 controls">
<label>Valor Total da Cirurgia<span>*</span></label>
<input type="text" class="form-control valor" id="valor_total" name="data[valor_cirurgia]" readonly="readonly">
<!-- <p id="valor_total">0,00</p> -->
</div>
</div>
Now the jquery:
function calculaSoma(){
var valor1 = $('input[name=data\\[valorc1\\]]');
var valor2 = $('input[name=data\\[valorc2\\]]');
var valor3 = $('input[name=data\\[valorc3\\]]');
var tot = (valor + valor1 + valor2);
var resultContainer = $('#valor_total');
resultContainer.html(tot.formatMoney(2,',','.'));
//alert(tot);
}
If anyone can help me?
well that you could post the complete and executable code, including the libraries used, so that we can do some tests
– user60252