• Resolved nicewp123

    (@nicewp123)


    Hello!
    Is it possible to do on fly calculations? For example, when I type new digit in NumberInputField, so that CalculationField updates automatically. Or if I stopped typing (i.e. timeout 500ms), then it updates. At the moment, you have to write your number, then click somewhere outside the field (not so intuitive), and only then calculations are updated. Do you have a solution for this? (maybe in javascript)
    Thanks!

    • This topic was modified 2 years, 4 months ago by nicewp123.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Jair – WPMU DEV Support

    (@wpmudevsupport15)

    Hi @nicewp123,

    I hope you are doing well today!

    This issue has been flagged to our SLS (Second Line Support) Team so that they can dig into this further. We will post an update here as soon as more information is available.

    Thank you for your patience while we look into this further.

    Kind regards,
    Zafer

    Plugin Support Jair – WPMU DEV Support

    (@wpmudevsupport15)

    Hi again @nicewp123,

    The following mu-plugin can help you to achieve it. You will need to change the form ID from 2910 to your form’s ID in this line
    if ( e.target.id == 'forminator-module-2910' ) { (edited)

    add_action('wp_footer', 'wpmudev_update_calculation_instant', 9999);
    function wpmudev_update_calculation_instant(){
    	global $post;
        if ( is_a( $post, 'WP_Post' ) && !has_shortcode($post->post_content, 'forminator_form') ) {
            return;
        }
    	?>
    	<script type="text/javascript">
    	jQuery(document).ready(function($){
    		setTimeout(function() {
    			$('.forminator-custom-form').trigger('after.load.forminator');
    		},100);
    
    		$(document).on('after.load.forminator', function(e, form_id) {
    			if ( e.target.id == 'forminator-module-2910' ) {
    				var typingTimer;
    				var doneTypingInterval = 500;
    				var $input = $('.forminator-number--field');
    
    				$input.each(function() {
    					$(this).on('keyup', function () {
    						clearTimeout(typingTimer);
    						typingTimer = setTimeout(doneTyping, doneTypingInterval);
    					});
    
    					$(this).on('keydown', function () {
    						clearTimeout(typingTimer);
    					});
    				})
    
    				function doneTyping () {
    					$input.trigger('change');
    				}
    			}
    		});
    	});
    	</script>
    	<?php
    }

    You can find more information below on how to use mu-plugins.
    https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins

    Must Use Plugins

    Kind regards,
    Zafer

    Thread Starter nicewp123

    (@nicewp123)

    @wpmudevsupport15, exactly what I need, thank you so much, Zafer, you are amazing!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘On fly calculations’ is closed to new replies.