Hello to everyone,
I have a form where I need to SUM two form fields to the third field - automatically after filling the fields before SUBMIT.
I am trying with this code :
but it doesnt works.
could you help me?
thx
I have a form where I need to SUM two form fields to the third field - automatically after filling the fields before SUBMIT.
I am trying with this code :
<script>form fields has 'price' in class and resulting field has id 'nezalistovane_0_cena_celkem'
$('.price').keyup(function () {
var sum = 0;
$('.price').each(function() {
sum += Number($(this).val());
});
$('#nezalistovane_0_cena_celkem').val(sum);
});
</script>
but it doesnt works.
could you help me?
thx
Hi homeopat,
I suggest that you use your browser web developr tools to debug your script. You can also add some debug lines to the code to see exactly what is happening.
Bob
I suggest that you use your browser web developr tools to debug your script. You can also add some debug lines to the code to see exactly what is happening.
Bob
Try replacing "$(" with "jQuery("
Bob: what debug liners do you mean? I am using standart Debug on
Healyhatma: didnt help
I did try this
I forgot said that these fields are in multiplier.
thx
Healyhatma: didnt help
I did try this
jQuery(document).ready(function() {but still not working.
jQuery('.form-control A').keyup(function () {
var sum = 0;
jQuery('.form-control A').each(function() {
sum *= Number(jQuery(this).val());
});
jQuery('#nezalistovane_0_cena_celkem').val(sum);
});
});
I forgot said that these fields are in multiplier.
thx
Where have you put this code? Have you tried custom javascript element in Designer, with document ready switched on? (And then obviously take out the jQuery(document).ready you have in there
Also and much more importantly: ('.form-control A') probably won't actually select anything, except maybe an "A" element (<a> ?)
inside an object with class form-control. Need to fix your selector.
Also and much more importantly: ('.form-control A') probably won't actually select anything, except maybe an "A" element (<a> ?)
inside an object with class form-control. Need to fix your selector.
I put this code to setup section - on load js script. I am not good in JS, so no I didnt try.
form-control A is name of the class of form fields . you have right, that the selector is not fixed, because each element has class form-control A. So I add to the mentioned field prefix price to the class.
form-control A is name of the class of form fields . you have right, that the selector is not fixed, because each element has class form-control A. So I add to the mentioned field prefix price to the class.
Names of things can't have spaces in them
but form-control A is made by chronoengine automatically.
You'll have to trust me on this buddy - you can't have spaces in a name. You've probably put a space in when you've named the items.
form-control A is not fill in class item (Builder). I have it empty and then I see form-control A in code in this item. when I add price to the class item in builder, then I see price form-control A in code of page.
Maybe we dont understand to each other.
Maybe we dont understand to each other.
Post pictures - of how you have the field set up in Designer, and of how the HTML code looks.
Here is example of 1 field in builder






<input name="nezalistovane[0][ks]" id="nezalistovane_0_ks" value="" placeholder="" maxlength="11" size="3" class="price form-control A" title="" style="" data-inputmask="" data-load-state="" data-tooltip="" type="text">
OK I see now - It's two classes.
jQuery('.form-control.A')
3 classes when I set price in builder of item .... i have other fields in form, what I dont need to count.
This topic is locked and no more replies can be posted.