Send form data to a modal window

Asked

Viewed 1,106 times

1

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

  • You already have boottrap modal html?

1 answer

1


Hello,

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

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>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.