I have these text inputs in a table :
<td><input type='text' name='arrondi_devis_ht' class='calcul_total' size='8'></td>
<td><input type='text' name='arrondi_devis_ttc' class='calcul_total' size='8'></td>
<td><input type="text" name='marge_pourcent' class='calcul_total' size='5' value='20,0'></td>
I successfully get their value by performing this :
var prix_unitaire_ht=parseFloat($(this).parents("tr").find('input[name="arrondi_devis_ht"]').val().replace(',','.'));
var prix_unitaire_ttc=parseFloat($(this).parents("tr").find('input[name="arrondi_devis_ttc"]').val().replace(',','.'));
var marge_pourcent=parseFloat($(this).parents("tr").find('input[name="marge_pourcent"]').val().replace(',','.'));
So i figured i could use a similar mechanism to set their values and tried this :
$(this).parents("tr").find('input[name="arrondi_devis_ht"]').value=new_prix_ht;
$(this).parents("tr").find('input[name="arrondi_devis_ttc"]').value=new_prix_ttc;
$(this).parents("tr").find('input[name="marge_pourcent"]').value=new_marge;
Yet it does not work and their value remain unchanged. I’ve tried with .val instead of value, also to assign them an id and to do find("#id").value instead of the above without any result.
Could anyone please tell me what I’m doing wrong ?
You need to use that
val()method to set the value of an input. This is what you are looking for:Since they are all in the same row, you may want to reuse the initial selector like so: