Welcome Guest, Not a member yet? Register   Sign In
problems in insert checkbox value and corresponding text value.
#5

(This post was last modified: 04-20-2019, 04:54 AM by kvanaraj.)

(04-16-2019, 08:02 AM)dave friend Wrote:
(04-16-2019, 06:13 AM)kvanaraj Wrote: I try your solution , but the output should be
certid[1] = 300
certid[2] = 300
certid[3] =
0

Please read my answer again and you will see I changed the values in the noc1 fields for demonstration purposes.
It is expected that you will put the values back to what you need for your application.

It was not at all clear that you wanted unchecked rows set to zero. With the information I have given you that should not be too hard to figure out. There are a number of different ways to determine what inputs are missing from the $certid array.
I attach complete my page source . i do know what mistake i ve done

Code:
<!-- list 1 -->


<?php foreach($getcert1 as $student1){        
       ?>
   <td width="50px" align="center">1</td>
   <td> Certificate 1</td>
   <td align="center">
     <input type = "checkbox" id="mycheck1" name="certid[]" class="checkbox"      
     value="1"  <?php echo set_checkbox($student1['certid'],'1',
     $student1['certid']==1);?> >
     </td>
   <td> 850 </td>
   

   <div class="col-xs-2">
   <td ><input type="text" id="totalamountremaining1"  name="txt[]" class="text-right" value = "<?php echo (!isset($student1['paid'])) ? 0 : $student1['paid'] ?>"  size="5"></td>
</div>  
 </tr>
<?php } ?>

<!-- list 2 -->

<?php foreach($getcert2 as $student2){
         ?>
   <td width="50px" align="center">2</td>
   <td>Certificate 2</td>
   <td align="center">
     <input type="checkbox" id="mycheck2" name="certid[]"  class="checkbox"      
     value="2"   <?php echo set_checkbox($student2['certid'],'1',
     $student2['certid']==2);?> >
     </td>
   <td> 300 </td>    
   
   <div class="col-xs-2">
   <td ><input type="text" id="totalamountremaining2"  name="txt[]" class="text-right" value="<?php echo (!isset($student2['paid'])) ? 0 : $student2['paid'] ?>"  size="5"></td>
</div>  
 </tr>
<?php } ?>


<!-- list 3 -->
 <?php foreach($getcert3 as $student3){  
       ?>
 <tr>
   <td width="50px" align="center">3</td>
   <td>Certificate 3</td>
   <td align="center"><input type="checkbox" id="mycheck3" name="certid[]" class="checkbox"  value="3" <?php echo set_checkbox($student3['certid'],'3',
     $student3['certid']==3);?>  > </td>
   <td> 300 </td>
   <td><input id="totalamountremaining3" type="text" name="txt[]" class="text-right"  value="<?php echo (!isset($student3['paid'])) ? 0 : $student3['paid'] ?>"  size="5"></td>
   
 </tr>
<?php } ?>
<!-- list 4 -->

<?php foreach($getcert4 as $student4){   ?>

 <tr>
   <td width="50px" align="center">4</td>
   <td>Certificate 4</td>
    <td align="center"><input type="checkbox" id="mycheck4" name="certid[]" value="4" class="checkbox"   <?php echo set_checkbox($student4['certid'],'1',
     $student4['certid']==4);?> > </td>
   <td> 300 </td>





   <td><input  id="totalamountremaining4" type="text" name="txt[]" class="text-right"  value="<?php echo (!isset($student4['paid'])) ? 0 : $student4['paid'] ?>" size="5"></td>
 
 </tr>
 <?php } ?>

<!-- list 5 -->

 <?php foreach($getcert5 as $student5){
       ?>
 <tr>
   <td width="50px" align="center">5</td>
   <td>Certificate 5</td>
   <td align="center"><input type="checkbox" id="mycheck5" name="certid[]" class="checkbox" value="5"  <?php echo set_checkbox($student5['certid'],'1',
     $student5['certid']==5);?> > </td>
   <td> 300 </td>
   <td><input id="totalamountremaining5" type="text" name="txt[]" class="text-right"  value="<?php echo (!isset($student5['paid'])) ? 0 : $student5['paid'] ?>" size="5"></td>
   
 </tr>
 <?php } ?>

 <!-- list 6 -->
 <?php foreach($getcert6 as $student6){
       ?>
 <tr>
   <td width="50px" align="center">6</td>
   <td>Certificate 6</td>
   <td align="center">

     <input type="checkbox" id="mycheck6" name="certid[]" value="6" class="checkbox" <?php echo set_checkbox($student6['certid'],'1',
     $student6['certid']==6);?> > </td>
   <td> 300 </td>
   <td><input  id="totalamountremaining6" type="text" name="txt[]" class="text-right"  value="<?php echo (!isset($student6['paid'])) ? 0 : $student6['paid'] ?>" size="5"></td>
   
 </tr>
 <?php } ?>

 <!-- list 7 -->
 <?php foreach($getcert7 as $student7){
       ?>
 <tr>
   <td width="50px" align="center">7</td>
   <td>Certificate 7</td>

   <td align="center"><input type="checkbox" id="mycheck7" name="certid[]" value="7" class="checkbox"  <?php echo set_checkbox($student7['certid'],'1',
     $student7['certid']==7);?> > </td>
   <td> 300 </td>
 


   <td><input  id="totalamountremaining7" type="text" name="txt[]" class="text-right"  value="<?php echo (!isset($student7['paid'])) ? 0 : $student7['paid'] ?>"  size="5"></td>
   
 </tr>
 <?php } ?>

 <tr>
   
   <td></td>
   <td><b><span id="sum1"></span></b></td>
    <td></td>
   
    <td><span><b>TOTAL</b></span></td>
    <td><input id="sum" type="text" name="sum" value="<?php echo (!isset($sum)) ? 0 : $sum ?>" class="text-right" size="5" ></td>
</tr>
Reply


Messages In This Thread
RE: problems in insert checkbox value and corresponding text value. - by kvanaraj - 04-20-2019, 01:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB