Hello @timobock
To create a logarithmic slider, you should customize the form’s code.
For example, assuming you want to apply this behavior to the slider field: fieldname16, insert an “HTML Content” field in the form with the following piece of code as its content:
<script>
fbuilderjQuery(document).one('showHideDepEvent', function () {
var $ = jQuery,
f = fbuilderjQuery.fbuilder.forms['_1'].getItem('fieldname16');
jQuery('#'+f.name+'_slider').slider('option', 'slide', null);
jQuery('#'+f.name+'_slider').slider('option', 'stop', null);
jQuery('#'+f.name+'_slider').on('slide stop', function (event, ui) {
var v = ROUND(expon(MAX(jQuery(this).slider('option', 'min'),1),
jQuery(this).slider('option', 'max'), ui.value));
$( '#'+f.name ).val( v );
$( '#'+f.name+'_caption' ).html(
f.caption
.replace( /\{\s*0\s*\}/, f._setThousandsSeparator( v ) )
);
$( '#'+f.name ).change();
});
});
function expon(min, max, val) {
var minv = Math.log(min);
var maxv = Math.log(max);
var scale = (maxv - minv) / (max - min);
return Math.exp(minv + scale * (val - min));
}
</script>
and that’s all.
Best regards.
-
This reply was modified 4 years, 8 months ago by
codepeople.