I found the answer to this question but with jQuery how to access an attribute of a select with jquery? and I have been trying to pass the response to javascript but I can't get it I leave the code here from the link
function elegirsaldo(el){ // recibimos por parametro el elemento select
// obtenemos la opción seleccionada .
var saldo = $('option:selected', el).attr('parametro2');
console.log(saldo);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select id="idgiftpro" onchange="elegirsaldo(this);">
<option value="0" parametro2="0">Seleccionar</option>
<option value="1" parametro2="10">50</option>
<option value="2" parametro2="20">100</option>
<option value="3" parametro2="30">200</option>
</select>
You can use
[selector].selectedOptions[0]
to get the selected option (selectedOptions
it can have more than one value if it ismultiple
)