I'm have some fields on a form that was cloned with the plugin Addel.
But when I clone them the function doesn't work. My code below:
  <!-- Valor -->
            <div class="form-group col-sm-2">
                {!! Form::label('valor', 'Valor:') !!}
                <div class="input-group">
                    <div class="input-group-addon">
                        <i class="fa fa-money"></i>
                    </div>
                    {!! Form::text('valor[]', null, ['class' => 'form-control','id' => 'valor']) !!}
                </div>
            </div>
            <!-- Desconto -->
            <div class="form-group col-sm-2">
                {!! Form::label('desconto', 'Desconto:') !!}
                <div class="input-group">
                    <div class="input-group-addon">
                        <i class="fa fa-percent"></i>
                    </div>
                    {!! Form::text('desconto[]', null, ['class' => 'form-control','id' => 'desconto']) !!}
                </div>
            </div>
            <!-- Valor Total -->
            <div class="form-group col-sm-2">
                {!! Form::label('valor_total', 'Valor Total:') !!}
                <div class="input-group">
                    <div class="input-group-addon">
                        <i class="fa fa-money"></i>
                    </div>
                    {!! Form::text('valor_total[]', null, ['class' => 'form-control','id' => 'valor_total', 'readonly']) !!}
                </div>
            </div>
The javascript function:
 <script>
    function moeda2float(moeda) {
        //retirar os pontos
        moeda = moeda.replace(".", "");
        //mudar a virgula pelo ponto
        moeda = moeda.replace(",", ".");
        //retornar em formato float
        return parseFloat(moeda);
    }
    function float2moeda(num) {
        x = 0;
        if (num < 0) {
            num = Math.abs(num);
            x = 1;
        }
        if (isNaN(num))
            num = "0";
        cents = Math.floor((num * 100 + 0.5) % 100);
        num = Math.floor((num * 100 + 0.5) / 100).toString();
        if (cents < 10)
            cents = "0" + cents;
        for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++)
            num = num.substring(0, num.length - (4 * i + 3)) + '.' + num.substring(num.length - (4 * i + 3));
        ret = num + ',' + cents;
        if (x == 1)
            ret = ' - ' + ret;
        return ret;
    }
    function calcular() {
        var total = 0;
        //recuperar o valor e transforma-lo em float
        var valor = $('#valor').val();
        valor = moeda2float(valor);
        //recuperar o valor e transforma-lo em porcentagem
        var desco = $('#desconto').val();
        desco = desco / 100;
        //calcular
        total = valor - valor * desco;
        //retornar o total em formato de moeda
        return float2moeda(total);
    }
    $('#valor, #desconto').blur(function(){
        $('#valor_total').val(calcular());
    });
</script>
 
    