0

I have created a form which contains a table, the purpose of this is table is to select the desired fees to manage

<form method="POST" action="manage_fees.php" id="manage_form">
     <table class="table table-striped table-bordered table-hover" id="table">
        <thead>
            <tr class="p-4">
            <th scope="col">Select</th>
            <th scope="col">School fees</th>
            <th scope="col">Amount</th>
            <th scope="col">type</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>              
            <div class="custom-control custom-checkbox">
            <input type="checkbox" class="custom-control-input check_amount" name="local_fees">
            <label class="custom-control-label" for="check_amount"></label>
            </div>
            </td>
            <td name="selected_fees">Local fees</td>
            <td name="amount">200</td>
            <td>University fees</td>
            </tr>
       </tbody>
     </table>
     <div class="modal-footer">
          <button type="submit" class="btn btn-primary" name="submit">Create</button>
     </div>
    </form>

Now I want to record it all data("fee name and total payment") that has checked in checkbox table and save in database using ajax.

Once the fees is selected it will display on the on input just like this

 <div class="form-group">
    label for="fs">Fees selected</label>
    <input type="text" class="form-control" id="fs" name="fs" required disabled>
 </div>
 <div class="form-group">
     <label for="tp">Total payment</label>
     <input type="number" class="form-control" id="tp" name="tp" required disabled>
 </div>

Now, the problem is that im having trouble saving the data that has been checked in table seems there is no data that has been pass in the input.

Sumbit.php

if(isset($_POST['submit'])){
$fs = $_POST['fs'];
$tp = $_POST['tp'];
$result = $connect->query("INSERT INTO manage_fees (fs,tp) VALUES ('$fs','$tp')") or die($connect->error());
}

Instead of this way how will send the data using ajax?

  • 1
    `disabled` values doesn't get submitted to server so easy fix will be using `readonly` attribute . Also , check [this](https://stackoverflow.com/questions/7357256/disabled-form-inputs-do-not-appear-in-the-request) post – Swati Apr 28 '21 at 13:48
  • and those two inputs are not inside form tag put them inside form tag . – Swati Apr 28 '21 at 13:52
  • Thank you again for you help! Now it works perfectly my problem right now is when you check 2 checkboxes it only saves the first checkbox value how will I get the data foreach checkbox that has been checked to save it in database? – Janbres Gagaracruz Apr 28 '21 at 15:12
  • Hi, sorry for late reply check [this](https://stackoverflow.com/questions/4997252/get-post-from-multiple-checkboxes) post . – Swati Apr 29 '21 at 04:18

0 Answers0