Hello @miikkaj
Thank you very much for using our plugin.
The number fields have spinner icons included by the browser. But if you prefer using button fields, you can follow the steps below:
1. Enter the spinner class name through its “Add CSS Layout Keywords” attribute in the number field.
2. Insert an “HTML Content” field in the form and enter the following piece of code through its content:
<script>
fbuilderjQuery(document).one('showHideDepEvent', function(){
jQuery('#fbuilder .spinner input')
.after('<button type="button" class="up">+</button>')
.before('<button type="button" class="down">-</button>');
});
jQuery(document).on( 'click', '#fbuilder .spinner .up', function(){
var e = jQuery(this).closest('.spinner').find('[type="number"]'), v = e.val()*1;
if(1 <= v) v = FLOOR(SUM(v,1));
else v = SUM(v,0.1);
e.val(PREC(v,1,true));
});
jQuery(document).on( 'click', '#fbuilder .spinner .down', function(){
var e = e = jQuery(this).closest('.spinner').find('[type="number"]'), v = e.val()*1;
if(1 < v) v = CEIL(v-1);
else v = v-0.1;
e.val(PREC(v,1,true));
});
</script>
Best regards.
Hi @codepeople
Your support is simply awesome. I think I’m going to update to Developer to support your business 🙂
But one more thing, using -+ buttons changes the values but the calculator’s dynamic evaluating is not working with this method. I have selected the option to eval on onchange and keyup events. The result updating requires typing the value.
What should I add to the code to enable the dynamic evaluating when -/+ buttons clicked?
Hello @miikkaj
Please, triggers the onchange event after assigning the field’s values.
Edit the piece of code e.val(PREC(v,1,true)); (please, note it appears twice in the block of code) as follows e.val(PREC(v,1,true)).change();
Best regards.