2016-12-08 38 views
1

我需要知道如何动态地添加类似的输入字段,如果总和的值增加输入字段> 0动态根据结果

让我解释一下,我有一个用户列表中的程序和各用户决定他/她是否支付一次付款或分期付款,所以这里是我遇到的问题,如果分期付款次数是按照示例2或10进行的,我怎样才能添加输入字段来显示剩余的分期付款数量在每个用户分期付款。

我有这行:

$honorario // is the total amount per subscription (4000.00) 
$nCuotas // is the number of installments to paid a total amount (10) 
$cantPagar // is the value of each installment for every month (400.00) 
$fPago // is for single payment or if the user will pay for installments (1 for single, 2 for installment) 

因此,如果用户选择一次性付款与分期付款的数量的形式留下来支付不会表现出来,但如果用户选择分期付款时,他/她登录程序,他/她会看到的形式输入字段的剩余数量支付

下面的示例代码:

<?php if($fPago != '1') { ?> 
<?php if($nCuotas >= '1') { ?> // Here I think need something like $i = $nCoutas to show equal form like a nCuotas the user have 
<form name="statusPago" id="statusPago" method="post"> 
<div class="form-group"> 
<input id="pago" name="pago" type="text" placeholder="100" value="" class="form-control" required="required"> 
</div> 
<div class="form-actions"> 
<input type="hidden" name="idCaso" value="<?php echo $idCaso; ?>"> 
<input type="submit" class="btn btn-primary" value="<?= trans('save'); ?>" /> 
<input type="reset" class="btn" value="<?= trans('reset'); ?>" /> 
</div> 
</form> 
<div id="loadStatus" style="display:none;"><img src="images/loading.gif" /></div> 
<?php } ?> 
<?php } ?> 

回答

1

我认为你正在寻找这样的:

<?php if($fPago != '1') { ?> 
    <?php if($nCuotas >= '1') { ?> // Here I think need something like $i = $nCoutas to show equal form like a nCuotas the user have 
     <form name="statusPago" id="statusPago" method="post"> 

      <?php for($i=0; $i< $nCuotas; $i++){ ?> 


      <div class="form-group"> 
       <input id="pago" name="pago[]" type="text" placeholder="100" value="" class="form-control" required="required"> 
      </div> 
      <div class="form-actions"> 
       <input type="hidden" name="idCaso[]" value="<?php echo $idCaso; ?>"> 
       <?php } ?> 

       <input type="submit" class="btn btn-primary" /> 
       <input type="reset" class="btn" /> 
      </div> 
     </form> 
     <div id="loadStatus" style="display:none;"><img src="images/loading.gif" /></div> 

    <?php } ?> 
<?php } ?> 

您可以var_dump($_POST['pago']);var_dump($_POST['idCaso']);表单值。