0

I am trying to get data from a form that is in a Bootstrap 3 modal. I want to use the data to write a query that deletes an entry from a database. Do I need to use jQuery and AJAX to get the data from the form in the modal to the query?

Here is my current code for the modal:

<!-- Modal -->
<div id="myModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Remove Absence</h4>
      </div>
      <div class="modal-body">

        <form id="insert_form" method="post">
            <section class="container-fluid">
                <div class="leftColumn">
                    <label>Student ID: </label><br>
                    <label>Date: </label>
                </div>
                <div class="rightColumn">
                    <input type="text" id="studentidRemoveAbs" placeholder="Student ID"><br>
                    <input type="text" id="yearRemove" placeholder="Year" value="2018" style="width: 60px;">
                    <input type="text" id="monthRemove" placeholder="Month" style="width: 60px;">
                    <input type="text" id="dayRemove" placeholder="Day" style="width: 60px;">
                </div>
            </section>
            <input type="submit" name='submitRemoveButton' class='navButton' value='Remove Absence' id="submitRemoveButton">
        </form>      
      </div>
      <div class="modal-footer">
        <button type="button" class="navButton" data-dismiss="modal">Close</button>
      </div>
    </div>
  </div>
</div>
Matt
  • 84
  • 9
  • Since you are connecting to database you have an option to use it this is primary opinion based – guradio Nov 13 '18 at 02:28
  • No you don't. But you can. https://stackoverflow.com/questions/1510011/how-does-ajax-work – Boby Nov 13 '18 at 02:29
  • Is there a way I could post the data from the form and use my query in the modal? I am using php for the serverside interactions – Matt Nov 13 '18 at 02:29
  • Can use native `fetch()` API or `XMLHttpRequest` to post the data and receive response – charlietfl Nov 13 '18 at 02:31
  • so where could I add the php to do that? – Matt Nov 13 '18 at 02:37
  • Suggest you study some tutorials on how ajax works – charlietfl Nov 13 '18 at 02:47
  • _“Is there a way I could post the data from the form and use my query in the modal?”_ - what do you even mean by that? What would “use the query in the modal” entail, in your opinion? Use it _for_ what, _in_ the modal? Are you simply asking how you could submit your form that is inside the modal? Well, like any other form, that it is in a modal does not make it special. – misorude Nov 13 '18 at 09:12

0 Answers0