我正在处理一个表单,该表单要动态显示/更新的值而input[text]无需提交表单。
以此为例:
传说:
price=$60 (固定值)
8 Kilo = 1 Spin[每8公斤等于1转。9kilos = 2Spins]
Amount = Spin*Price
当用户在“ kilo”中输入10时,“ spin”值将被更新,并且“ amount”值将被自动计算。用户键入时,计算应实时进行。
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> https://stackoverflow.com/questions/ask# <table class="table table-striped table-bordered table-hover " id="dataTables-example"> <tr> <th>ID</th> <th>SERVICE</th> <th>KILO</th> <th>SPINS</th> <th>PRICE</th> <th>AMOUNT</th> </tr> <tr> <form id="new_transaction" method="post" class="form-horizontal" action="scripts/add_transaction.php"> <td>1</td> <td>WASH</td> <td> <div class="form-group"> <div class="col-sm-12"> <input type="text" class="form-control" name="kilo" id="kilo1"> </div> </div> </td> <td> <div class="form-group"> <div class="col-sm-12"> <input type="text" class="form-control" name="spins" readonly> </div> </div> </td> <td> <div class="form-group"> <div class="col-sm-12"> <input type="text" class="form-control" name="price" value="$60" readonly> </div> </div> </td> <td> <div class="form-group"> <div class="col-sm-12"> <input type="text" class="form-control" name="amount"readonly> </div> </div> </td> </tr> </form> </table>