18910140161

HTML-JavaScript更新字段堆栈溢出

顺晟科技

2022-10-19 14:37:35

20

我面临一个问题,在输入值到输入字段时,我需要更新一个值。 还有一个从laravel框架中的数据库中提取的变量。

我有一个字段,该字段取应付总额,并将eftpos附加费应用于该金额,作为通过eftpos支付的金额的参考。

我想根据新的余额是现金/支票还是奖学金金额(因为这不需要缴纳eftpos附加费)来更新此字段。这个想法是为了确保我们正确地将EFTPOS附加费应用于EFTPOS金额。

HTML代码

 <table class="table">
     <thead class="text-primary">
         <th class="text-center">Method</th>
         <th class="text-center">Amount</th>
         <th></th>
     </thead>
     <tbody>
         <tr>
             <td class="text-center">EFTPOS</td>
             <td class="text-center">$ <input type="number" step="0.01" name="eftpos"></td>
             <td class="text-center"><a id="eftpos"> ${{ number_format(($income + $student->AdditionalItems->where('paid', 0)->sum('amount'))*(1+$eftpos), 2)}}</a> - Including Surcharge</td>
         </tr>
         <tr>
             <td class="text-center">Cash</td>
             <td class="text-center" id="cash">$ <input type="number" step="0.01" name="cash"></td>
             <td></td>
           </tr>
           <tr>
              <td class="text-center">Cheque</td>
              <td class="text-center" id="cheque">$ <input type="number" step="0.01" name="cheque"></td>
              <td></td>
          </tr>
          <tr>
              <td class="text-center">Scholarship</td>
              <td class="text-center" id="scholarship">$ <input type="number" step="0.01" name="scholarship"></td>
              <td></td>
          </tr>
      </tbody>
  </table>

JavaScript代码

 <table class="table">
     <thead class="text-primary">
         <th class="text-center">Method</th>
         <th class="text-center">Amount</th>
         <th></th>
     </thead>
     <tbody>
         <tr>
             <td class="text-center">EFTPOS</td>
             <td class="text-center">$ <input type="number" step="0.01" name="eftpos"></td>
             <td class="text-center"><a id="eftpos"> ${{ number_format(($income + $student->AdditionalItems->where('paid', 0)->sum('amount'))*(1+$eftpos), 2)}}</a> - Including Surcharge</td>
         </tr>
         <tr>
             <td class="text-center">Cash</td>
             <td class="text-center" id="cash">$ <input type="number" step="0.01" name="cash"></td>
             <td></td>
           </tr>
           <tr>
              <td class="text-center">Cheque</td>
              <td class="text-center" id="cheque">$ <input type="number" step="0.01" name="cheque"></td>
              <td></td>
          </tr>
          <tr>
              <td class="text-center">Scholarship</td>
              <td class="text-center" id="scholarship">$ <input type="number" step="0.01" name="scholarship"></td>
              <td></td>
          </tr>
      </tbody>
  </table>

$EFTPOS是由laravel控制器传递的

提前感谢您的帮助


顺晟科技:

  • TAG:
相关文章
我们已经准备好了,你呢?
2024我们与您携手共赢,为您的企业形象保驾护航