Navigation überspringen

[Gelöst] Date Time field change the option on the minutes select field

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem:
Customer would like to change the option on the minutes field to 15-minute increments (0, 15, 30, 45).
Solution:
It is possible to use some jQuery to customize it and change the values of the select field.

Please add the following code to the javascript section of the form:

(function($, window) {
  $.fn.replaceOptions = function(options) {
    var self, $option;
 
    this.empty();
    self = this;
 
    $.each(options, function(index, option) {
      $option = $("<option></option>")
        .attr("value", option.value)
        .text(option.text);
      self.append($option);
    });
  };
})(jQuery, window);
 
var options = [
  {text: "0", value: 1},
  {text: "15", value: 2},
  {text: "30", value: 3},
  {text: "45", value: 4},
];
 
 jQuery("select[name$=\'minute]\']").replaceOptions(options);
This support ticket is created vor 1 year, 8 months. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 -

Zeitzone des Unterstützers: America/Sao_Paulo (GMT-03:00)

Dieses Thema enthält 1 reply, hat 2 Stimmen.

Zuletzt aktualisiert von Mateus Getulio vor 1 year, 8 months.

Assistiert von: Mateus Getulio.

Author
Artikel
#2691829
thumbnail_image.png

Hey,

I would like to change the option on the minutes field to 15-minute increments (0, 15, 30, 45). Is that possible? can you please advise?

#2691916

Mateus Getulio
Unterstützer

Sprachen: Englisch (English )

Zeitzone: America/Sao_Paulo (GMT-03:00)

Hello there,

Currently, there's no built-in solution for you to customize the minutes in the select field.

However, you could use some jQuery to customize it and change the values of the select field.

Please add the following code to the javascript section of the form and test it if it works:

(function($, window) {
  $.fn.replaceOptions = function(options) {
    var self, $option;

    this.empty();
    self = this;

    $.each(options, function(index, option) {
      $option = $("<option></option>")
        .attr("value", option.value)
        .text(option.text);
      self.append($option);
    });
  };
})(jQuery, window);

var options = [
  {text: "0", value: 1},
  {text: "15", value: 2},
  {text: "30", value: 3},
  {text: "45", value: 4},
];

 jQuery("select[name$=\'minute]\']").replaceOptions(options);

I tested it and it worked fine for me.

Thank you, please let us know.
Mateus