0

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);
    }
0

1 Answer 1

0

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);
}
Sign up to request clarification or add additional context in comments.

2 Comments

but different Js file
should still work

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.