I need to split the value of my html select option and pass the split results into two separate input fields. I tried to code this before but ended up with a not so DRY result.
Could someone help me understand how to pass an array's value to each element in another array? This was even confusing to write. :(
This is what I have so far;
$(document).ready(function() {
$('#media-size').change(function() {
var selectValue = $(this).val();
var arr = selectValue.split("x");
var valOne = arr[0];
var valTwo = arr[1];
$('.media-value').each(function() {
$(this).val(arr);
});
});
});
Here's a link to the fiddle I've been working on; Click Here
Any guidance would be much appreciated.
Regards, -B.
P.s.
To clarify, before this question is marked as a duplicate. I'm looking for a Jquery answer, not a java answer which is all I seem to be able to find on the subject.
.media-valueinputs? Or more?