function openForm(id) {
  document.getElementById("myForm").style.display = "block";
  document.forms['datacapture']['rin'].value = id;
}

$(function() {
        var $form = $('#datacapture');
         $form.submit(function (e) {
            e.preventDefault();
            $.ajax({
                type: 'POST',
                url: $form.attr('action'),
                data: $form.serialize(),
                success: function (response) {
                    $form[0].reset();
                    closeForm();
                }
            });
        });
    });
      
function closeForm() {
  document.forms['datacapture']['rin'].value = "";
  document.getElementById("myForm").style.display = "none";
}