PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Time Field to Default to PM, not AM

  1. Hi,

    I would like the time field to Default to PM, not AM. Is this possible?

    URL - http://www.diskman.net/clients/dreams/packages/gold-party-package-registration/

    Thanks,

    Bella

    Posted 11 years ago on Tuesday May 21, 2013 | Permalink
  2. Richard Vav
    Administrator

    Hi Bella,

    Try the following script, you can add it above or below the form embed shortcode on the page containing your form.

    <script>
    jQuery(document).ready(function($) {
        $('#input_4_13_3').val('pm');
    });
    </script>

    The above will just work on that specific time field, if you have time fields on multiple forms which you want to do the same for then I can adjust the script and create a function that you could place in your functions.php file.

    Regards,
    Richard

    Posted 11 years ago on Tuesday May 21, 2013 | Permalink
  3. Hi Richard, that worked a treat!

    Yes I do have more than one form requiring the change so if not too much trouble I would love a script for the functions.php.

    Many thanks in advance for your help, much appreciated!

    Bella

    Posted 11 years ago on Tuesday May 21, 2013 | Permalink
  4. Richard Vav
    Administrator

    Hi Bella,

    You're welcome, add the following to your functions.php file and remove the earlier script from your page.

    add_action('gform_pre_render','set_time_pm');
    function set_time_pm($form){
    ?>
    <script>
        jQuery(document).ready(function($){
            $('.gfield_time_ampm select').val('pm');
        });
    </script>
    <?php
    	return $form;
    }

    As it is the above function will print the script on all forms, if you only wanted it to appear on form 4 for example you would edit the add action so it looks like this

    add_action('gform_pre_render_4','set_time_pm');

    if you wanted to target forms 4 and 7 for example you would add a second add action for form seven like so

    add_action('gform_pre_render_4','set_time_pm');
    add_action('gform_pre_render_7','set_time_pm');

    Regards,
    Richard

    Posted 11 years ago on Tuesday May 21, 2013 | Permalink