how make jquery ignore an option from a select menu

32 Views Asked by At

I have this select menu with these options, which is in a form which performs a mathematical operation with the value that is inside the value attribute, but always selects by default when counting the value of the selected option disabled .

<li><label for="menuPlazos" class="labelInputs">Plazos de cancelacion: </label><select name="menuPlazos" id="menuPlazos" class="inputsValues">
            <option type="number" value="" disabled selected>Elegi una Opcion</option>
            <option type="number" value="12">12 meses</option>
            <option type="number" value="24">24 meses</option>
            <option type="number" value="36">36 meses</option>
        </select></li>

I use this JS code to change another value, and works

function cambiarValorTasas() {
let plazosOpc = $("#menuPlazos").prop("selectedIndex");
let opciones = $("#menuPlazos").prop("options");
if (opciones[plazosOpc].value == 12) {
    $("#tasasSeleccion").html(3.95);
} else if (opciones[plazosOpc].value == 24) {
    $("#tasasSeleccion").html(4.19);
} else if (opciones[plazosOpc].value == 36) {
    $("#tasasSeleccion").html(4.36);
}
return $("#tasasSeleccion").val();

}

With JS I change the value of another field by altering this within the options, but when changing it in chrome / safari / brave, it does not take that value as valid (the value of the options, only returns NaN) (it only works in firefox with the code as I use it today), now if I delete the selected disabled option, everything works correctly in all browsers. How can I make JS ignore this value?

in this method applied to the client object, it returns is NaN

    client.creacionClientes(
    $("#nombre").val(),
    $("#apellido").val(),
    $("#mail").val(),
    parseInt($("#aSolicitar").val()),
    parseInt($("#menuPlazos").val()),
    parseFloat(tasas),
    parseFloat($(".valorCuota").text()).toFixed(2)
);
0

There are 0 best solutions below