Select value in select and add selected value to input

0

The idea is that you can select certain values in an input and that the selected value is added to an input. If you select 100 for example in the input you must add 100, then if I select another value for example the 200 should remove the value previously selected and now add the one that was selected now that would be 200.

    
asked by Kinafune 26.08.2018 в 17:30
source

1 answer

0

It could be done with javascript like this:

var select = document.getElementById();//id de el select
var input = document.getElementById();//id del input

select.addEventListener("change", event => {
    input.value = parseInt(input.value) + parseInt(select.value);
});
    
answered by 26.08.2018 в 17:33