TOPIC:

Age Calcualtion 3 weeks 5 days ago #260942

  • Topic Author
  • papin0
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Posts: 143
  • Thanks: 0
I need help configuring where to put the code exactly to find out the Age based on a Date field.
This is what I have but is not working for me.
//CHANGE SECTIONS & FIELDS FORMAT
function ff_newreferralform_init()
{
//HERE YOU CHANGE TITLE TEXT WEIGHT FOR SECTIONS
jQuery("#reference legend").css("font-weight","bold");
jQuery("#demographics legend").css("font-weight","bold");
jQuery("#medicalinfo legend").css("font-weight","bold");
jQuery("#servreq legend").css("font-weight","bold");
jQuery("#external_services legend").css("font-weight","bold");
jQuery("#insurance legend").css("font-weight","bold");
jQuery("#referralsourcesec legend").css("font-weight","bold");
jQuery("#disclaimer legend").css("font-weight","bold");
jQuery("#concerns legend").css("font-weight","bold");
jQuery("#external_serv legend").css("font-weight","bold");
jQuery("#parent_guardian legend").css("font-weight","bold");
jQuery("#legalguardian_sec legend").css("font-weight","bold");
jQuery("#who legend").css("font-weight","bold");
jQuery("#contact legend").css("font-weight","bold");
jQuery("#stats legend").css("font-weight","bold");
jQuery("#choices legend").css("font-weight","bold");
jQuery("#legalguardian legend").css("font-weight","bold");
jQuery("#caregivers legend").css("font-weight","bold");
jQuery("#school legend").css("font-weight","bold");
jQuery("#PCPsec legend").css("font-weight","bold");
jQuery("#treatmentinfo legend").css("font-weight","bold");
jQuery("#priinsinfo legend").css("font-weight","bold");
jQuery("#secinsinfo legend").css("font-weight","bold");
jQuery("#external1 legend").css("font-weight","bold");
jQuery("#familymembers legend").css("font-weight","bold");
jQuery("#services_needed legend").css("font-weight","bold");
jQuery("#attachdocs2 legend").css("font-weight","bold");
jQuery("#req_pro legend").css("font-weight","bold");

//HERE YOU CHANGE TITLE TEXT SIZE FOR SECTIONS
jQuery("#main_address legend").css("font-size","17px");
jQuery("#click_code legend").css("font-size","14px");
jQuery("#click_symptom legend").css("font-size","14px");
jQuery("#reason_for_referral legend").css("font-size","14px");
jQuery("#services_needed legend").css("font-size","17px");
jQuery("#enterfullname legend").css("font-size","17px");
jQuery("#familymembers legend").css("font-size","17px");
jQuery("#external_serv legend").css("font-size","18px");
jQuery("#req_pro legend").css("font-size","18px");
jQuery("#concerns legend").css("font-size","18px");
jQuery("#services_needed legend").css("font-size","17px");
jQuery("#attachdocs2 legend").css("font-size","17px");
jQuery("#external1 legend").css("font-size","18px");
jQuery("#parent_guardian legend").css("font-size","20px");
jQuery("#legalguardian_sec legend").css("font-size","20px");
jQuery("#parents legend").css("font-size","17px");
jQuery("#emergency legend").css("font-size","17px");
jQuery("#priinsinfo legend").css("font-size","18px");
jQuery("#secinsinfo legend").css("font-size","18px");
jQuery("#referring_agency legend").css("font-size","18px");
jQuery("#person_referring legend").css("font-size","18px");
jQuery("#previous_tx legend").css("font-size","14px");
jQuery("#current_tx legend").css("font-size","14px");

//HERE YOU CHANGE TITLE FONT STYLE FOR SECTIONS
//jQuery("#external_serv legend").css("font-style","italic");
//jQuery("#parent_guardian legend").css("font-style","italic");
//jQuery("#legalguardian_sec legend").css("font-style","italic");

//HERE YOU CHANGE TITLE TEXT COLOR FOR SECTIONS
//jQuery("#external_serv legend").css("color","blue");
//jQuery("#parent_guardian legend").css("color","blue");
//jQuery("#legalguardian_sec legend").css("color","blue");
//END HERE YOU CHANGE TITLE TEXT COLOR FOR SECTIONS

//HERE YOU SEARCH SELECT LIST WITH A TEXT FIELDS
jQuery('[name="ff_nm_searchcode[]"]').keydown(function() {
jQuery('[name="ff_nm_ICD10_select[]"] option').prop('hidden', false);
jQuery('[name="ff_nm_ICD10_select[]"] option').not(jQuery('[name="ff_nm_ICD10_select[]"] option:icontains('+ff_getElementByName('searchcode').value+')')).prop('hidden', true);
});
jQuery('[name="ff_nm_searchsymptoms[]"]').keydown(function() {
jQuery('[name="ff_nm_symptoms_select[]"] option').prop('hidden', false);
jQuery('[name="ff_nm_symptoms_select[]"] option').not(jQuery('[name="ff_nm_symptoms_select[]"] option:icontains('+ff_getElementByName('searchsymptoms').value+')')).prop('hidden', true);
});
//HERE YOU LOAD THE ADD/DELETE WRAPPER SCRIPT
{
  WrapperScriptAddDelete();
  AddDeletePreTreatment();
}// ff_WrapperForm_init
//END HERE YOU LOAD THE ADD/DELETE WRAPPER SCRIPT

ff_age_init();

} // ff_newreferralform_init

//HERE YOU SEARCH IN CAPS/LOWER CASE WITHIN THE SELECT LIST WITH A TEXT FIELD
jQuery.expr[':'].icontains = function(a, i, m) {
return jQuery(a).text().toUpperCase()
.indexOf(m[3].toUpperCase()) >= 0;
};
//END HERE YOU SEARCH SELECT LIST WITH A TEXT FIELDS

function ff_age_init()
{
setInterval('ageCal()', 500);
} // ff_age_init

function ageCal() {
var dateOfBirth = ff_getElementByName('dob').value;
var today = new Date();
var birthDate = new Date(dateOfBirth);
var age = today.getFullYear() - birthDate.getFullYear();
var m = today.getMonth() - birthDate.getMonth();
console.log(m);
if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) {
age--;
ff_getElementByName('age').value = age;
}
}

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

Last edit: Post by papin0.

Age Calcualtion 3 weeks 4 days ago #260950

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

could you please check your previous post?

There I fixed your code
crosstec.org/en/forums/coding-consultanc...html?start=12#260947

Please let me know the result

Regards,
Tihana

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

Last edit: Post by tihana.krivic.

Age Calcualtion 3 weeks 3 days ago #261015

  • Topic Author
  • papin0
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Posts: 143
  • Thanks: 0
Got it.

I change the Calendar field for a text field and it worked.

the only issue I still have is that I cannot use the value from the Age field to hide/unhide a section.

turn off section parents if age is <18
turn on section parents if age is >17

Attachments:

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

Last edit: Post by papin0.

Age Calcualtion 3 weeks 3 days ago #261022

  • Mirec's Avatar
  • Mirec
  • Offline
  • Gold Breezer
  • Gold Breezer
  • Posts: 454
  • Karma: 2
  • Thanks: 19
Hi,

Try like this:
In Field age GO-> Advenced->ActionScript type 'Costum':
function ff_age_action(element, action)
{
    switch (action) {
        case 'change':

if (jQuery('[name="ff_nm_age[]"]').val() < 18) {
bfToggleFields('on','section','parents',bfDeactivateField);
}else{
bfToggleFields('off','section','parents',bfDeactivateField);
}
            break;
        default:;
    } // switch
} // ff_age_action
[code]

Instead [code](jQuery('[name="ff_nm_age[]"]')
function ff_age_action
'age' insert name of field (not title).

Regards,
Mirko

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

Last edit: Post by Mirec.

Age Calcualtion 3 weeks 3 days ago #261028

  • Topic Author
  • papin0
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Posts: 143
  • Thanks: 0
when I clear the date field the Age field keeps the value

Attachments:

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

Age Calcualtion 3 weeks 2 days ago #261035

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

if you want to use Mirko's script from message above in form->Advanced->Visibility rules must be this:
turn on element mydummy if yourdummy is something
Otherwise bfToggle method will not work

Don't change anything, leave it as it

Regards,
Tihana

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

Moderators: ForumSupport
Time to create page: 0.125 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!