If the form is selected in the initial state, the data is passed. But the cloning form doesn't pass data from the select to the next form. If I duplicate the form at the beginning it also passes the data. But I want the cloned form to pass the data.
$('input#clone').click(function() {
$("div#old").clone().attr('id', 'new_form').appendTo("body")
})
$(".product").change(function() {
newPrice = $(this).children(':selected').data('price');
$(this).parent().next('.pricebox').find('.price').val(newPrice);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="button" value="Clone" id="clone" />
<hr>
<div id="old">
<div class="">
<select class="product" name="product[]">
<option value="1" data-price="1.99">1</option>
<option value="2" data-price="2.99">2</option>
<option value="3" data-price="3.99">3</option>
<option value="4" data-price="4.99">4</option>
</select>
</div>
<div class="pricebox">
<input type="text" name="price[]" class="price" value="00" />
</div>
</div>