Nan Resultado

Nan Resultado

by Angelo Rogério Rubin

HTML

<select id="somacontas">
    <option value="Participant">Participante</option>
    <option value="Student">Estudante</option>
</select>

<select id="typeRoom">
    <option value="150.00">Pobre</option>
    <option id="dinner" value="500.00">Rico</option>
</select>

<p id="bookprice"></p>
<p id="total"></p>

JavaScript

$("#somacontas").change(function(){
    //Arranjar tipo participante 195 | 80
    var choice = $(this).val();
    // var student = $(this).val();
    
    if (choice == "Participant"){
        var mT = 195;
    }
    else if (choice == "Student"){
        mT = 80;
    }
    else {
        mT = 0;
    }
    
    var x = $('#typeRoom option:selected').val();  
    var c = parseInt($('#typeRoom option:selected').val(), 10);
    var y = 0;
    
    if($("#dinner").is(':checked')) {    
        y = 45;
    }
    else {
        y = 0;
    }
    
    $("#bookprice").html(x).append(".00 €");
    var totalPrecoR = c + y;
    var totalPreco = c + y + mT;
    $("#total").html(totalPreco).append(".00 €");
  
});