G
G
Goldsliders2021-06-06 00:22:05
JavaScript
Goldsliders, 2021-06-06 00:22:05

How to write to the input value, vale several real-time values ​​at once?

Goodnight !
Please tell
me I have a diagram

<input name="1" type="text" id="1" value="">
<input name="2" type="text" id="2" value="">
<input name="3" type="text" id="3" value="">
<input name="4" type="text" id="4" value="">

how can I write in the first one, the value of the value of all the others separated by commas in real time, that is, I
fill in the second input, for example, and in the first one, value immediately appears I

WILL BE GRATEFUL FOR THE EXAMPLE!
THANKS IN ADVANCE!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2021-06-06
@Goldsliders

const [ first, ...rest ] = document.querySelectorAll('input');
const onInput = () => first.value = rest.map(n => n.value).join(', ');
rest.forEach(n => n.addEventListener('input', onInput));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question