• Resolved kimcoetzee

    (@kimcoetzee)


    Hello

    I have 2 date fields. fieldname2 and fieldname3. I have set fieldname2 to always be today and fieldname3 to be 1.

    But if a site visitor changes fieldname2 to for example to next week Monday. Is there a way that fieldname3 can then at that moment change to next week Tuesday?

    Thanks

    The page I need help with: [log in to see the link]

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

    (@codepeople)

    Hello @kimcoetzee

    Thank you very much for using our plugin. Yes, that’s possible.

    You should insert an “HTML Content” field in the form and enter the following piece of code as its content:

    <script>fbuilderjQuery(document).on(
    'change',
    '[id*="fieldname2_"].hasDatepicker',
    function (){
    var d = fbuilderjQuery(this).datepicker('getDate');
    d.setDate(d.getDate()+1);
    fbuilderjQuery('[id*="fieldname3_"].hasDatepicker').datepicker('setDate',d); });</script>

    More information in the following section of the plugin’s documentation:

    https://cff.dwbooster.com/documentation#relationship-between-date-fields

    Best regards.

    Thread Starter kimcoetzee

    (@kimcoetzee)

    Thank you, that worked beautifully. unfortunately, I noticed that should one decide to change fieldname3 to another date that, the other date does not get submitted when the form is processed.

    Is there a way to ensure that the site visitors’ selection is the date that gets submitted?

    Plugin Author codepeople

    (@codepeople)

    Hello @kimcoetzee

    Please, includes an onchange event in the piece of code I sent you in the previous entry:

    <script>fbuilderjQuery(document).on(
    'change',
    '[id*="fieldname2_"].hasDatepicker',
    function (){
    var d = fbuilderjQuery(this).datepicker('getDate');
    d.setDate(d.getDate()+1);
    fbuilderjQuery('[id*="fieldname3_"].hasDatepicker').datepicker('setDate',d).change(); });</script>

    Best regards.

    Thread Starter kimcoetzee

    (@kimcoetzee)

    Hi, Thank You but that, unfortunately, did not work.

    Plugin Author codepeople

    (@codepeople)

    Hello @kimcoetzee

    I tested your form and it worked fine. I was redirected to the new page with the correct URL parameters:

    https://be.synxis.com/?adult=3&arrive=2022-06-22&chain=24885&child=0&currency=ZAR&depart=2022-06-23&hotel=7483&level=hotel&locale=en-US&rooms=1

    Best regards.

    Thread Starter kimcoetzee

    (@kimcoetzee)

    Hello Apologies for the long delay getting back to you. As per your example please use 2022-07-22 and 2022-07-26

    And then you will see that the code is not working.

    You will see that regardless of what is in fieldname3 that the fieldname3 date submitted always reverts back to fieldname2 plus 1.

    Thread Starter kimcoetzee

    (@kimcoetzee)

    NB I have since moved on to a different URL. Please use https://rio.peermontdev.co.za/ to see what I mean.

    Plugin Author codepeople

    (@codepeople)

    Hello @kimcoetzee

    You are using the same field to generate the departure and arrival parameters in the URL:

    window.open(generateURL('https://be.synxis.com/', {
    	adult: getField('fieldname4').val(),
    	arrive: CDATE(getField('fieldname2').val()),
    	chain: getField('fieldname17').val(),
    	child: getField('fieldname5').val(),
    	currency: JSON.parse(getField('fieldname19').val()),
    	depart: CDATE(getField('fieldname2').val()),
    	hotel: getField('fieldname1').val(),
    	level: getField('fieldname18').val(),
    	promo: JSON.parse(getField('fieldname6').val()),
    }), '_blank');

    Pay attention to the lines of code:

    arrive: CDATE(getField('fieldname2').val()),

    and

    depart: CDATE(getField('fieldname2').val()),

    Please, note the support service does not cover the implementation of the users’ projects. If you need that me to implement your project, you can contact me directly through my private website: Customization

    Best regards.

    Thread Starter kimcoetzee

    (@kimcoetzee)

    Wonderful, it works. Thank you very much.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘How to make default date one day more than another date field’ is closed to new replies.