• Resolved facemail4me

    (@facemail4me)


    hi, I’m looking for a way to read the date from a datepicker and calculate the day from it and put it into a hidden input so I can use it in Conditional Logic.
    Is there a good way in Ninja Forms? Since I have a more paged form this kind of thing doesn’t work:

    var datepicker = document.getElementsByClassName('datepicker');
    
    Array.prototype.forEach.call(datepicker, function(el) {
        el.addEventListener('input', function(el){
            var date1 = el.value().split("/")
            var day = new Date(date1[2],date1[1]-1, date1[0]).getDay()
            document.getElementsById('nf-field-299').value = day
        });
        el.addEventListener('change', function(el){
            var date1 = el.value().split("/")
            var day = new Date(date1[2],date1[1]-1, date1[0]).getDay()
            document.getElementsById('nf-field-299').value = day
        });
    });

    I would be very happy about help

Viewing 1 replies (of 1 total)
  • Thread Starter facemail4me

    (@facemail4me)

    okay, I’ve now figured out how to do something about changing the form.
    How do I get it now that I can read stalls from other fields or set values.
    Somehow in the same direction as I tried in the setHidden function.

    document.addEventListener("DOMContentLoaded", function(event) {
      var myCustomFieldController = Marionette.Object.extend({
      
        inaitialize: function() {
            var fieldsChannel = Backbone.Radio.channel( 'fields' );
            this.listenTo( fieldsChannel, 'change:modelValue', this.setHidden(fieldsChannel) );
        },
        
        setHidden: function(model, fields ) {
            var location = fields.get(273)
            var location1 = fields.get(274)
            var location2 = fields.get(275)
            console.log(location)
            console.log(location1)
            console.log(location2)
        }   
      });
      new myCustomFieldController();
    });
    • This reply was modified 11 months, 1 week ago by facemail4me.
Viewing 1 replies (of 1 total)
  • The topic ‘Day of a Datepicker’ is closed to new replies.