【问题标题】:dynamically add input field according result根据结果​​动态添加输入字段
【发布时间】:2016-12-08 17:30:16
【问题描述】:

如果总和的值> 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 } ?>

【问题讨论】:

    标签: php input dynamic


    【解决方案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']); 获取表单值。

    【讨论】:

      猜你喜欢
      • 2021-05-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多