When you click on a name, it appears in another div

1

I have a project developed in Bootstrap, where clicking link Products will open a Bootstrap Modal with the products listed. However, I would like you to click on one of the products to close the modal and the clicked product would appear in a <div> under the link clicked. Until the modal and the product listing I was able to do it, but the product name underneath the link clicked I could not. Could someone help me?

<script type="text/javascript">
    function Aparecer(produto){
      var nome;
      document.getElementById("Produtos").innerHTML = produto;
    }
  </script>
<a href="#" onclick="javascript:Aparecer(<?php echo $produto; ?>)">Selecionar</a>
<div id="Produtos"></div>
    
asked by anonymous 01.07.2015 / 20:22

2 answers

1

Place an id in div below the Products link (say: id="produtoSelecionado" ).

Now just use it in Javascript, along with modal closing (I assume the use of jQuery):

function Aparecer(produto){
  document.getElementById("produtoSelecionado").innerHTML = produto;
  $('#myModal').modal('hide');
}
    
02.07.2015 / 15:13
0

Hello, I think I'm missing the quotes in .

try this: '

02.07.2015 / 14:08