• Resolved ondesk007

    (@ondesk007)


    I have two inputs

    1. Miles
    2. Minutes

    I want to get output how many times will require for each mile.

    If i give 2 miles and 15 minutes it’s showing 7.5 as result which should show 7.3 that means 7 minutes and 30 seconds

    How can i do this calculation

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Support Williams – WPMU DEV Support

    (@wpmudev-support8)

    Hi @ondesk007

    I hope you’re well today!

    The calculation field doesn’t take into account the “type” of calculated data and doesn’t handle any “conversions” and non-numerical characters.

    So even if you calculate results in all in seconds – simply by multiplying result by 60 – it will still not let you convert that to actual time display.

    It might be possible with a bit of additional calculations and custom code but would also require additional field to display results. I have asked our developers if we would be able to provide you with such solution so please stay tuned and we’ll update you here again once we got feedback on this.

    Best regards,
    Adam

    Thread Starter ondesk007

    (@ondesk007)

    thank you for your reply

    lets wait then

    Plugin Support Kris – WPMU DEV Support

    (@wpmudevsupport13)

    Hi @ondesk007

    Please try this snippet as a mu-plugin

    add_action( 'wp_footer', 'wpmudev_convert_calculation_time', 9999 );
    function wpmudev_convert_calculation_time(){
    	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( $('#forminator-module-2878').length ) {
    				$(document).on('input', '#forminator-field-number-1, #forminator-field-number-2', function(){
    					var val1 = $('#forminator-field-number-1').val();
    					var val2 = $('#forminator-field-number-2').val();
    					if( val1 && val2 ) {
    						var calculated_time = (+val2)/(+val1);
    						calculated_time = calculated_time.toFixed(2);
    						var index = calculated_time.lastIndexOf('.');
    						var before = '';
    						var after = '';
    						if (index !== -1) {
    							before = calculated_time.slice(0, index);
    							after = calculated_time.slice(index + 1);
    							after = ((+after)*60)/100;
    							$('#forminator-field-text-1').val(before+' minutes '+ after + ' seconds');
    						}
    					}
    				});
    			}
    		});
    	});
    	</script>
    	<?php
    }

    In the snippet you need to change the form ID here “#forminator-module-2878”. Also, field IDs are test, so they need to change them if you have different in your form.

    ref.: https://www.ads-software.com/support/article/must-use-plugins/

    Kind Regards,
    Kris

    Thread Starter ondesk007

    (@ondesk007)

    I have Created mu-plugins directory in wp-content

    location now : wp-content/mu-plugins and then created a php file pac.php and putted code snippet you send me.

    then created 2 number fields to get number (miles and time) & added a calculation button. I thought Calculation for Formula i will have to keep it empty (as your code will take action) but it’s asking me to put Calculation Formula.

    If all looks good to you then, what should i put in formula section?

    Thank You`

    • This reply was modified 2 years, 3 months ago by ondesk007.
    Thread Starter ondesk007

    (@ondesk007)

    Waiting for Reply

    • This reply was modified 2 years, 3 months ago by ondesk007.
    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @ondesk007

    I hope you are doing well.

    You can find a full guide on https://wpmudev.com/blog/wordpress-mu-plugins/ or https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins

    Another method is using this plugin https://www.ads-software.com/plugins/code-snippets/ but the mu-plugin method is a better idea.

    Best Regards
    Patrick Freitas

    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @ondesk007

    Sorry for the previous reply,

    I can see you were able now to add the mu-plugin.

    then created 2 number fields to get number (miles and time) & added a calculation button. I thought Calculation for Formula i will have to keep it empty (as your code will take action) but it’s asking me to put Calculation Formula.

    If all looks good to you then, what should i put in formula section?

    Our developers created this sample form for you:

    https://pastebin.com/ELg7mUR6

    You can import to your Forminator https://wpmudev.com/docs/wpmu-dev-plugins/forminator/#import-export to find out how to manage the custom code.

    Best Regards
    Patrick Freitas

    Plugin Support Amin – WPMU DEV Support

    (@wpmudev-support2)

    Hello @ondesk007 ,

    We haven’t heard from you for several days now, so it looks like you don’t need our assistance anymore.

    Feel free to re-open this ticket if needed.

    Kind regards
    Kasia

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Decimal to Minute format’ is closed to new replies.