• Resolved 121940kz

    (@121940kz)


    I have 2 input dates. One is the current date, and the other is a fixed date. However, the fixed date would need to be updated every year. For example the fixed date is 03/01/2018. Is there a way to use a smart string to have 03/01/y so that the y is always the current year? I have tried everything but can’t figure out if this is possible.

    Thanks,

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @121940kz,

    I’ll try to describe the process with an example. Assuming the date field is the fieldname1, you simply should insert a “HTML Content” field in the form with the following piece of code as its content:

    
    <script>
    fbuilderjQuery(document).one('showHideDepEvent', function(){
    var year = (new Date()).getFullYear();
    fbuilderjQuery('[id*="fieldname1_"].hasDatepicker').val('03/01/'+year).change();
    });
    </script>
    

    and that’s all.
    Best regards.

    Thread Starter 121940kz

    (@121940kz)

    Thank you, it works good. I didn’t know you could use the html content type to do that. I also wrote some extra code to change the date on selection change of another date picker. Thanks again!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Dynamically Set Date’ is closed to new replies.