Calling JavaScript within Modal

1

Is it possible to get a result of a JavaScript function and play this result inside a Modal?

I have this function:

<script>

$('#download').click(function() {
    document.getElementById('xxxx').disabled=false
    document.getElementById('xxxx').disabled=false

    var formData = $(document.forms[0]).serialize().split('&').join('\n');


    this.href = 'data: ,' +  formData ;




    document.getElementById('xxxx').disabled=true
    document.getElementById('xxxxx').disabled=true

});

</script>   

The result "formData" would have to be played within a modal Popup. His code:

<div class="bs-example">
    <!-- Button HTML (to Trigger Modal) -->
    <a href="#myModal" class="btn btn-lg btn-primary" data-toggle="modal" >Clique aqui para ver a janela</a>
   <!-- Modal HTML -->
    <div id="myModal" class="modal fade">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title">Atenção!</h4>
                </div>
                <div class="modal-body">

                    </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
                    <button type="button" class="btn btn-primary">Salvar tudo</button>
                </div>
            </div>
        </div>
    </div>
</div> 
    
asked by anonymous 25.08.2016 / 00:21

2 answers

0

Expensive;

I solved my problem with the code below:

function copy_form()
    {
id('modalxxx').value = id('xxx').value;
id('modalyyy').value = id('yyy').value;
id('modalrrr').value = id('rrr').value;
id('modalttt').value = id('ttt').value;


    }

 function id( el ){
  return document.getElementById( el );
                  }
    window.onload = function()
       {
    id('btnenviar').onclick = function()
       }
    copy_form();
      }
   }

</script> 

Thanks for the help:)

    
31.08.2016 / 23:57
0

You can give an ID to the div that will receive the content

<div class="modal-body" id="conteudoModal">

And then after form data

var formData = $(document.forms[0]).serialize().split('&').join('\n');
document.getElementById('conteudoModal').innerHTML(formData);

Would that be?

    
25.08.2016 / 02:21