i can't get input value when changed by select
how i get input value?
thank you
/* file script 1 */
var select = document.getElementById('select');
select.onchange=(e)=>{
const val = e.target.value ;
input.value=val;
}
/* file script 2 */
var input = document.getElementById('input');
input.onchange= (e)=>{
console.log(e.target.value);
}
First of all, input has no onchange attribute, use oninput instead and after you change the value of the input field just call oninput:
select.onchange = (e) => {
const val = e.target.value ;
input.value=val;
input.oninput();
}
input.oninput = (e) => {
console.log(e.target.value);
}