-1

I have some input fields and one html table in a form and I want to send all data including all rows from the table to php function in a codeigniter controller. my table data is filled dynamically by using javascript.

 <form method="POST" >

                <input type="text" class="form-control" id="pname" placeholder="Enter Patient name here" name="pname"  >

                <input type="number" class="form-control" id="p-age" name="p-age"  >
 
            <input type="radio" id="male" name="sex" value="male"  >
            <label for="male" class="receipt-label mr-2">Male</label>

            <input type="radio" id="female" name="sex" value="female"  >
            <label for="female" class="receipt-label mr-2">Female</label>


        <table class="table" id="dest_table" >
        <thead class="thead-dark">
          <tr>
          <th scope="col">Test ID</th>
            <th scope="col">Test Name</th>
            <th scope="col">Price</th>
            <th scope="col" style="text-align:center;">Action</th>
          </tr>
        </thead>
        <tbody>
                    </tbody>
                    </table>



        <button type="submit" name="submit" class="btn btn-info btn-lg" id = "submit">Print</button>                    

       </form>               
3
  • 1
    Possible duplicate of stackoverflow.com/questions/27314062 Commented Nov 24, 2022 at 21:12
  • 1
    add hidden input fields when populating the table dynamically Commented Nov 24, 2022 at 21:20
  • What have you tried so far? Where are you stuck? Is this a JS problem or a PHP problem? Commented Nov 25, 2022 at 7:54

1 Answer 1

0

Just add some hidden fields in the table

<form method="POST" >
    
                    <input type="text" class="form-control" id="pname" placeholder="Enter Patient name here" name="pname"  >
    
                    <input type="number" class="form-control" id="p-age" name="p-age"  >
     
                <input type="radio" id="male" name="sex" value="male"  >
                <label for="male" class="receipt-label mr-2">Male</label>
    
                <input type="radio" id="female" name="sex" value="female"  >
                <label for="female" class="receipt-label mr-2">Female</label>
    
    
            <table class="table" id="dest_table" >
            <input type="hidden" name="hid-box" value="1" /> 
            <thead class="thead-dark">
              <tr>
              <th scope="col">Test ID</th>
                <th scope="col">Test Name</th>
                <th scope="col">Price</th>
                <th scope="col" style="text-align:center;">Action</th>
              </tr>
            </thead>
            <tbody>
                        </tbody>
                        </table>
    
    
    
            <button type="submit" name="submit" class="btn btn-info btn-lg" id = "submit">Print</button>                    
    
           </form> 

          
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.