How to write to input selected values from select statement if (input and select) a dynamic?

Well, clarification: in the loop creates an unknown number of blocks (the number depends on the data in the database), each block is input select and how to get this input, to record changing values in the select statement to identify-it is impossible?
June 26th 19 at 14:00
1 answer
June 26th 19 at 14:02
Solution
Something like, for example:
$('select').on('change', function(){ // on change event
 var sel = $(this)
 sel.closest('.block') // looks for the closest parent .block (wrapper, combining select and input)
 .find('input') // it looks for input
 .val(sel.val()) // and writes the value
})

If the markup is simple, and the select and input do not have any extra wrappers, then closest + find can be simplified to .siblings('input')
SPS) did not know about the method closest - fatim commented on June 26th 19 at 14:05
there's even vanilla js added. - Austen.Thompson53 commented on June 26th 19 at 14:08
: I js don't know very well, all indirectly aimed not studied it) - fatim commented on June 26th 19 at 14:11
one more question, if inputов the block a few?) I classes necessary to define to search only in the wrapper within the limit of the block? or is it impossible? - fatim commented on June 26th 19 at 14:14
: you can of course. - Austen.Thompson53 commented on June 26th 19 at 14:17

Find more questions by tags JavaScriptHTMLjQueryPug