I need to get the value that i typed in the modal input field, when i press enter, the modal will close, and the input value that i typed will be displayed in another input field outside the modal.
$('#myModal2').on('keydown', function(e)
{
if (e.which == 13)
{
e.preventDefault();
var value = $(this).find('td:eq(myInput2)').text();
document.getElementById("my_member").value = value;
$("[data-dismiss=modal]").trigger(
{
type: "click"
});
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- modal button -->
<button type="button" class="btn btn-outline-secondary" style="background-
color:#e6e6e6; " data-toggle="modal" data-target="#myModal2"
id="btnproduct2" name="btnproduct2">...</button>
<!-- input field inside modal -->
<div class="modal fade" id="myModal2" role="dialog">
<input type="text" class="form-control" placeholder="ID..." id="myInput2"
autocomplete="off" />
</div>
<!-- input field outside modal -->
<input type="text" class="form-control" name="my_member" style="width:75%;"
id="my_member" value="" autocomplete="off">