- Posts: 20
- Thank you received: 2
Ask the community, share ideas, and connect with other LimeSurvey users!
My opinion : if you don't know how to do it in JS : it's more complicated than in HTML directly …bebs wrote: …
My case has many more products, subcategories and different languages... so manually creating the summary question each time is too dangerous wrt updates.
…
Any ideas ? Would there be a better option with a temporary JS structure that would contain the weights, or other ?
Thanks in advance.
Berteh
<tr> <td>{pp_B.question}</td> <td>B</td> <td>{Q1_1_B}</td> <td>{Q1_2_B}</td> <td>{Q1_3_B}</td> <td>{Q1_4_B}</td> <td>{round(sum(ww_1*Q1_1_B, ww_2*Q1_2_B, ww_3*Q1_3_B, ww_4*Q1_4_B))}</td> <td>{pp_B} €</td> <td>{round(sum(ww_1*Q1_1_B, ww_2*Q1_2_B, ww_3*Q1_3_B, ww_4*Q1_4_B)*pp_B)}</td> </tr> <tr> <td>{pp_O.question}</td> <td>O</td> <td>{Q1_1_O}</td> <td>{Q1_2_O}</td> <td>{Q1_3_O}</td> <td>{Q1_4_O}</td> <td>{round(sum(ww_1*Q1_1_O, ww_2*Q1_2_O, ww_3*Q1_3_O, ww_4*Q1_4_O))}</td> <td>{pp_O} €</td> <td>{round(sum(ww_1*Q1_1_O, ww_2*Q1_2_O, ww_3*Q1_3_O, ww_4*Q1_4_O)*pp_O)}</td> </tr>
Try something like this:Or should I stick to jQuery, but then what event should I bind my "quantity" and "subtotal" update methods to ? $('input.numeric-item').change() does not seem to do the trick, as its .val() does not seem to always reflect the proper value.
$('input.numeric-item').on('keyup paste', function(e) { // Do something... });
$('.autoVdA input[name$="_price"]').attr('disabled', 'disabled').addClass('price auto');
$('#'+subID+'_price').val(price);
$('.autoVdA table.subquestion-list input').change(function() { var subID = $( this ).attr('id').split("_")[0]; (...) $('#'+subID+'_subto').val((qty * price).toFixed(1)); });
$('.autoVdA input[name$="_price"]').prop('readonly', true).addClass('price auto');
$('.autoVdA table.subquestion-list input').on('keyup change', function(e) { var subID = $( this ).attr('id').split("_")[0]; (...) $('#'+subID+'_subto').val((qty * price).toFixed(1)); });