html - PHP: Passing Foreach Data Values to Input Boxes while incrementing the number of their ID and Name -
hi guys summarize problem here hope understand.
main goal: main goal have foreach of datas , pass designated input boxes while, in same way i'm appending number of id , name
already accomplished: have forloop of x can increment , pass values array in input boxed id , name
html code:
<table class="table table-bordered" id="addsubpaymenttable"> <thead> <tr> <th>particulars</th> <th>balance</th> <th>payment amount</th> </thead> <tbody> <?php $arraynumber = 0; for($x = 1; $x < 2; $x++) { ?> //this make loop increment x supply diffrent number values same id , name have input boxes. <tr id="row<?php echo $x; ?>" class="<?php echo $arraynumber; ?>"> //increment rows <td class="form-group"> <input type="text" class="form-control" name="subparticulars[<?php echo $x; ?>]" id="subparticulars<?php echo $x; ?>" placeholder="particulars" /> </td> //you notice x inside name , id of subparticulars. <td class="form-group"> <input type="text" class="form-control" name="subpaymentbalance[<?php echo $x; ?>]" id="subpaymentbalance<?php echo $x; ?>" onclick="copybalance(<?php echo $x; ?>)" placeholder="balance" readonly /> </td> <td class="form-group"> <input type="text" class="form-control" name="subpaymentamount[<?php echo $x; ?>]" id="subpaymentamount<?php echo $x; ?>" onkeyup="calculatetotalamount(); calculateremainingbalance(<?php echo $x; ?>);" placeholder="payment amount" /> </td> </tr> <?php $arraynumber++; } // end of foreach ?> </tbody> </table>
main problem main problem how can possibly insert values of data in example can use foreach ($datavalues values) {} in input boxes @ same time increment id , name number.
purpose: above code originated in add row function increments rows when clicking add row, needed change other goals didn't need add row anymore , have transfer values of each instead of selecting particulars, , it's hassle add row enter different particulars instead of showing , add payment amounts.
the answer question:
use foreach($studentfeesdata $x => $studentfees)
<table class="table table-bordered" id="addsubpaymenttable"> <thead> <tr> <th style="width:36%;">particulars</th> <th style="width:32%;">balance</th> <th style="width:32%;">payment amount</th> </thead> <tbody> <?php $arraynumber = 0; foreach($studentfeesdata $x => $studentfees) { ?> <tr id="row<?php echo $x; ?>" class="<?php echo $arraynumber; ?>"> <td class="form-group"> <select class="form-control" name="subparticulars[<?php echo $x; ?>]" id="subparticulars<?php echo $x; ?>" readonly/> <option value = "<?php echo $studentfees['feetype_id']; ?>"> <?php echo $studentfees['feetype_name']; ?> </option> </select> </td> <td class="form-group"> <input type="text" class="form-control" name="subpaymentbalance[<?php echo $x; ?>]" id="subpaymentbalance<?php echo $x; ?>" onclick="copybalance(<?php echo $x; ?>)" value="<?php echo $studentfees['feestudent_amount']; ?>" readonly /> </td> <td class="form-group"> <input type="text" class="form-control" name="subpaymentamount[<?php echo $x; ?>]" id="subpaymentamount<?php echo $x; ?>" onkeyup="calculatetotalamount(); calculateremainingbalance(<?php echo $x; ?>);" placeholder="payment amount" /> </td> </tr> <?php $arraynumber++; } // /.foreach?> </tbody> </table>
Comments
Post a Comment