TOPIC:

Field responding to calendar selection 3 months 1 week ago #243059

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Posts: 1261
  • Karma: 3
  • Thanks: 110
Hi,

Great :D

For NaN I will need to do some additional coding. Sorry I forgot.
I'll do it so I'll get back to you.

Also, please keep us motivated by leaving a small review here:
extensions.joomla.org/extension/contacts...orms/breezing-forms/
(Please turn off your VPN and local Apache prior reviewing as your review might get blocked)

Thank you.

Regards,
Tihana

Please Log in or Create an account to join the conversation.

Field responding to calendar selection 3 months 1 week ago #243134

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Posts: 1261
  • Karma: 3
  • Thanks: 110
Hi,

Here is:
function ff_formname_init()
{ setInterval( calc, 500);
} // ff_formname_init

function calc() {
var calend = ff_getElementByName('nameofelementcalendar').value.split(".");
var d = new Date(calend[2], Number(calend[1]-1), calend[0]);
d.setMonth(d.getMonth() + 12);
var mj = ("0" +(d.getMonth()+ 1)).slice(-2);
if(isNaN(mj)) {
  return "";
}
ff_getElementByName('nameofelementtext').value=(("0"+ d.getDate()).slice(-2))+ "."+ mj + "."+d.getFullYear() ; 
}

Note: If the month is NaN returns an empty field.
if(isNaN(mj)) {
  return "";
}
This stop displaying NaN before a date is selected

Regards,
Tihana
The following user(s) said Thank You: macross

Please Log in or Create an account to join the conversation.

Field responding to calendar selection 1 month 4 weeks ago #245905

  • Topic Author
  • macross
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 68
  • Thanks: 0
Hello again,

I was wondering if you could also help me with adding just 14 days to the selected calendar instead of a whole year. Example: If I select the 1st of August the corresponding field should display the 15th of August.

How do I have to modify this code to get there?
function ff_formname_init()
{ setInterval( calc, 500);
} // ff_formname_init

function calc() {
var calend = ff_getElementByName('nameofelementcalendar').value.split(".");
var d = new Date(calend[2], Number(calend[1]-1), calend[0]);
d.setMonth(d.getMonth() + 12);
var mj = ("0" +(d.getMonth()+ 1)).slice(-2);
if(isNaN(mj)) {
  return "";
}
ff_getElementByName('nameofelementtext').value=(("0"+ d.getDate()).slice(-2))+ "."+ mj + "."+d.getFullYear() ; 
}

Thank you :)

Please Log in or Create an account to join the conversation.

Field responding to calendar selection 1 month 4 weeks ago #245908

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Posts: 1261
  • Karma: 3
  • Thanks: 110
Hi,

Like this:
function ff_formname_init()
{ setInterval( calc, 500);
} // ff_formname_init

function calc() {
var calend = ff_getElementByName('nameofelementcalendar').value.split(".");
var d = new Date(calend[2], Number(calend[1]-1), calend[0]);
d.setDate(d.getDate()+14);
d.setMonth(d.getMonth() + 12);
var da=("0" +(d.getDate())).slice(-2);
var mj = ("0" +(d.getMonth()+ 1)).slice(-2);
if(isNaN(mj)) {
  return "";
}
ff_getElementByName('nameofelementtext').value=da + "."+ mj + "."+d.getFullYear() ; 
}

Let me know if it works for you

Regards,
Tihana

Please Log in or Create an account to join the conversation.

Field responding to calendar selection 1 month 4 weeks ago #245933

  • Topic Author
  • macross
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 68
  • Thanks: 0
Hi, thanks for the quick response!

For this case I would like it to just add 14 Days not also a year

I tried myself and ALMOST got it to work, this is my code:
function calc() {
var calend = ff_getElementByName('calendar').value.split(".");
var d = new Date(calend[2], calend[1], calend[0]);
d.setDate(d.getDate()+14);
var da=("0" +(d.getDate())).slice(-2);
if(isNaN(da)) {
  return "";
}
ff_getElementByName('responding').value=da + "."+ (("0"+ d.getMonth()).slice(-2)) + "."+d.getFullYear() ;
}

So this does what I want, if I select let's say the 1st of August, then the corresponding field says 15th of August, which is perfect.

BUT if I select a date at the end of the month let's say the 21st of August it says 5th of September, which is one day too late...

I'm sorry to ask again but I need your help with this again x)

Please Log in or Create an account to join the conversation.

Field responding to calendar selection 1 month 4 weeks ago #245938

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Posts: 1261
  • Karma: 3
  • Thanks: 110
Hi,

Like this:
function calc() {
var calend = ff_getElementByName('calendar').value.split(".");
var d = new Date(calend[2], calend[1], calend[0]);
d.setDate(d.getDate()+13);
var da=("0" +(d.getDate()+1)).slice(-2);
if(isNaN(da)) {
  return "";
}
ff_getElementByName('responding').value=da + "."+ (("0"+ d.getMonth()).slice(-2)) + "."+d.getFullYear() ;
}

Regards,
Tihana

Please Log in or Create an account to join the conversation.

Moderators: ForumSupport
Time to create page: 0.053 seconds

BreezingForms Pro 1.4.7 for WordPress Released!

Available in the membership section.

September Discount!

Massive discounts on all subscriptions!

Get Your Subscription Here

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Special Offer

Summer Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!