Home Passing data from a from to bootstrap modal using PHP
Reply: 0

Passing data from a from to bootstrap modal using PHP

user2050 Published in June 20, 2018, 1:32 am

I wanted to pass a data to a modal from this textbox using PHP

Textbox code:

 <input type="text" id="weights" class="form-control" placeholder="Weight (lbs)" name="weight">

This is the button code:

<button type="button" class="btn btn-primary btn-block" data-toggle="modal" data-target="#exampleModalCenter" id="buttonx">Submit</button>

Jquery Code:

 $(document).ready(function() {
  $('#exampleModalCenter').on('show.bs.modal', function(e) {
    var weight = document.getElementById("weights");
      type: 'post',
      url: 'showResult.php',
      data: 'weight=' + weight,
      success: function(data) {

Modal Code:

<div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLongTitle">Results</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                          <span aria-hidden="true">&times;</span>
      <div class="modal-body" id="fetched-data">

      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>



echo "The weight is $data";

When i click the button, nothing really shows up. Even the modal, doesn't show up.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.320568 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO