1
Until now my code was using a sum of values
Example:
const inputs = [...document.querySelectorAll("input[class='serv']")];
const res = document.getElementById("resultado");
const total = res.querySelector('[name="total"]');
const serv = res.querySelector('[name="serv"]');
inputs.forEach(x => x.addEventListener("change", () => {
    total.value = inputs.filter(el => el.checked).reduce((sum, el) => sum + Number(el.value), 0);
    serv.value = inputs.filter(el => el.checked).map(el => el.name).join(',');
}));<div id="resultado" class="col">
    <div class="input-group">
        <div class="input-group-prepend">
            <span class="input-group-text bg-primary text-white">Serviços</span>
        </div>
        <input type="text" class="input-group-text" placeholder="0,00" name="total" value="" readonly="readonly">
        <input type="hidden" name="serv" value="">
    </div>
</div>
<div class="form-group">
    <label for="">Desconto: </label>
    <select class="form-control form-control-sm" name="desconto">
        <option value=""></option>
        <option value="5%">Desconto Pai e Filho</option>
        <option value="10%">Amigo da Hora</option>
        <option value="15%">Familia</option>
    </select>
</div>
<br>
<div class="row">
    <table class="table">
        <tbody>
            <tr>
                <td><input type=checkbox class='serv' name="" value="10"> Serviço</td>
                <td>10</td>
            </tr>
            <tr>
                <td><input type=checkbox class='serv' name="" value="15"> outro Serviço</td>
                <td>15</td>
            </tr>
        </tbody>
    </table>
</div>i would like to know how to include a discount when it is selected.
it was exactly this situation, but that way it doesn’t work precisely... after selecting a discount when selecting another, it cashes in the value already discounted and not in the real value and also could not return to the real value when I selected the option blank.
– Ronaldo de Lima