Send data from a form to a modal window

1

I am developing a simple form and when submitting the form, instead of sending it to another page "result.php", I would like to open a modal window using the bootstrap, to show the summary of this post and it is possible, a link to copy the result to the transfer area (contrl + c). How to "load" form field values in modal ??

    
asked by anonymous 02.03.2016 / 21:00

1 answer

1

Hello,

Creating the model with the elements you want to display, each item of the form is just to create an ID for each and create a JS function in the "submit" button that would assign the value of each form input to each element of the model .

Example:

    <form>
        <input id="inputRandom" value="blabla"/>
        <button id="submit">Submeter</button>
    </form>

    <div class="modal">
      <span id="mostraValorInput"></span>
    </div>

<script>
     $("#submit").click(function (){
     $("#mostraValorInput").text($("#inputRandom").val());
     });

</script>
    
02.03.2016 / 21:59