Create form for Wix site calculation

0

I'm having trouble creating a code to use on my WIX site. I would like the site to present 4 fields for the user to complete: v1, v2, v3 and v4, where v4 is currency. A fifth field would display the value of the following account:

v1/100 * v2 * v3/50

In the sixth field I would like you to display v4 * v5 as the currency as well (v5 = v1/100 * v2 * v3/50 result). And finally in the seventh field the multiplication of v6 * 24 . You do not even need to label the fields because I edit with visual elements later.

    
asked by anonymous 01.03.2017 / 11:47

1 answer

0

The results appear after completing the first 4 inputs.

    $(document).ready(function() {
    $('.somente-numero').keyup(function (e) {
        $(this).val($(this).val().replace(/[^0-9\.]/g,''));
        var v1 = Number(document.getElementById("v1").value);
        var v2 = Number(document.getElementById("v2").value);
        var v3 = Number(document.getElementById("v3").value);
        var v4 = Number(document.getElementById("v4").value);
        var v5 = document.getElementById("v5").value = (v1/100 * v2 * v3/50);
        var v6 = document.getElementById("v6").value = parseFloat(v4 * v5).toFixed(2);
        var v7 = document.getElementById("v7").value = parseFloat(v4 * v5 * 24).toFixed(2);
    });
    });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><form><label>Capacidadedocesto(kg)</label><inputtype="text" class="somente-numero" 
name="v1" id="v1" size="10" /> 
<label>Porcentagem de açúcar final (%)</label> <input type="text" class="somente-numero" 
name="v2" id="v2" size="10"/> 
<label>Ciclos por hora</label> <input type="text" class="somente-numero" name="v3" 
id="v3" size="10" />
<label>Valor da saca 50kg do açúcar (R$)</label> <input type="text" class="somente-numero" 
name="v4" id="v4" size="10" /><br>
<label>Desfalque na produção (sacas)</label> <input type="text" name="v5" 
id="v5" size="10" readonly />
<label>Prejuízo por hora (R$)</label> <input type="text" name="v6" id="v6" size="10" 
readonly />
<label>Prejuízo ao longo de 24h (R$)</label> <input type="text" name="v7" 
id="v7" size="10" readonly />
</form>
    
01.03.2017 / 13:20