javascript - Display data on blur -


i have simple table (dynamically generated array) can put amount of pieces price can calculate automaticly (on blur) in price field. both fields form-input fields.
source therefore looks this:

<?php  foreach($itemarray['1'] $key => $value) {  echo ' <tr>     <td height="30" valign="middle">'.$value['nr'].'</td>     <td valign="middle">'.$value['product'].'</td>     <td valign="middle">'.$value['describe'].'</td>      <td valign="middle" id="stockprice_'.$key.'">     <input name="field_price_'.$key.'" id="field_price_'.$key.'" value="'.$value['price'].'" type="text" /></td>      <td valign="middle" class="box_darker" id="amount_'.$key.'">     <input name="field_amount_'.$key.'" id="field_amount_'.$key.'" type="text" /></td>      <td valign="middle" id="price_'.$key.'">     <input name="field_total_'.$key.'" id="field_total_'.$key.'" type="text" />     </td> </tr>'; } ;?>   

the way realize when user inputs amount (in "field_amount_") , go out (onblur) amount field should take value (from "field_amount_") , have put total price (in "field_total_"). try solution, won't work.

$(document).on('blur', '[id^=field_amount_]', function(){      amount = $(this).parent().find('[id^=field_amount_]').val();     stockprice = $(this).parent().find('[id^=field_price_]').val();     price = $(this).parent().find('[id^=field_total_]');     rowprice = amount * stockprice;      if(amount) { $(price).text(accounting.formatnumber(rowprice, 2, ".", ","));} });  

can give me suggestion how have this? many thanks.

thanks lot helping me.

change selector [id^=field_amount_] input[id^=field_amount_]


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -