Try with this
$(function(){
//when click a button
$("#miButton").click(function(){
$(".dynamic-field").remove();
//pass the data in the modal body adding html elements
$('#myModal .modal-body').html('<input type="hidden" name="name" value="your value" class="dynamic-field">') ;
//open the modal
$('#myModal').modal('show')
})
})