5
Good afternoon! I’m trying to make a modal to fetch the products and assign it to the input. Idea: When I click on the input, it opens the modal. Then I choose the product in the modal and it loads the input with the data of the chosen product.
Product name input (Has an Hidden input to store product id as well):
<td>
<input type="text" name="produtoNF[0].nome" value="${produtoNF[0].nome}" onclick="getProduto()"/>
</td>
Modal choosing the product:
<div class="modal fade" id="findProduct" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Buscar produto</h4>
</div>
<div class="modal-body">
<ul id="ulItens" style="list-style-type: none">
<c:forEach itens="${productList}" var="product">
<li>
<span>${product.id}</span> -
<span>${product.nome}</span>
</li>
</c:forEach>
</ul>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Fechar</button>
</div>
</div>
</div>
</div>
Java Script:
function getPessoa() {
$("#busPes").modal("show");
}
function setPessoa(id, nome) {
$('#id').val(id);
$('#nome').val(nome);
$('#busPes').modal('hide');
}
I was able to make a static input, but when I create the dynamic input, (I have a button that creates another row in the table with inputs), I am not able to understand how to store the chosen value in the modal input I click to open the modal.
As I’m starting out, I had a hard time explaining it, too. Thank you.
You could post the javascript you are using in the process?
– lenilsondc
@Lenilsondecastro, I had done this for the person who was just a static input. I put javascript in the post
– Fabberg