How to pass the data from a checked checkbox to a modal?

0

I would like to know how I can, when selecting a checkbox, take this data and throw it in a modal. In the code below, I want to pick only the selected charters from a post and make only those selected appear in the modal. How do I do? I've tried to see in other tutorials, but I could not find something to help me. Many thanks!

<div ng-repeat="charter in post.charters">
    <input type="checkbox" ng-model="charter.selected"> &nbsp; {{'{{charter}}'}}
</div>

<div class="modal fade textfield" id="updatePopUp">
     <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-label="Close">
              <span aria-hidden="true">&times;</span>
          </button>
          <h4 class="modal-title" id="exampleModalLabel" >Edit Post Components</h4>
     </div>
     <div class="modal-body">
     <form>
         <div class="form-group form-inline">
              <label for="txtComponent" class="control-label">Component:</label>
              <input type="text" class="form-control" ng-model="post.components" id="txtComponent" autocomplete="off" placeholder="Insert a component">
              <button ng-click="searchCharters(post.components)" type="button" class="btn btn-primary">See charters</button>
         </div>
     </form>
     <ul>
         <div ng-repeat="charter in post.charters">
             {{'{{charter}}'}}
         </div>
     </ul>
</div>

<div class="modal-footer">
    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
    <button ng-click="updatePost()" type="button" class="btn btn-primary">Update</button>
 </div>
    
asked by anonymous 06.10.2017 / 17:15

1 answer

0

function setaDadosModal(nome) {

  document.getElementById('nome_confirma').innerHTML = nome;

}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><scriptsrc="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<td>


  <!-- Exemplo com botao para enviar os dados para o modal -->
  <a style="text-decoration: none" data-toggle="modal" data-target="#modal_confirmacao"><button  type="button" class="btn btn-block btn-danger" onclick="setaDadosModal('id do campo ou palavha')">Enviar para modal</button></a></td>







<!-- Modal -->
<div class="modal fade" id="modal_confirmacao" role="dialog">
  <div class="modal-dialog">
    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header callout callout-danger">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title text-center">modal headero</h4>
      </div>
      <div class="modal-body">
        <h5 class="text-center">
          você enviou o campo <label value="nome_confirma" id="nome_confirma"></label>?
        </h5>
        <input style="display: none" type="text" name="id_inativar" id="id_inativar">
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
      </div>
    </div>
  </div>
function setaDadosModal (name, id) {     document.getElementById ('name_confirm'). innerHTML = name;     document.getElementById ('id_enable'). value = id; }     
06.10.2017 / 17:41