Bienvenido, Invitado
Recordarme

TEMA:

Age Calcualtion 10 meses 3 semanas antes #260942

  • Autor del tema
  • papin0
  • Fuera de línea
  • Expert Breezer
  • Expert Breezer
  • Mensajes: 208
  • Gracias recibidas: 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;
}
}

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Última Edición: Post by papin0.

Age Calcualtion 10 meses 3 semanas antes #260950

  • Avatar de tihana.krivic
  • tihana.krivic
  • Fuera de línea
  • Moderator
  • Moderator
  • Mensajes: 10135
  • Karma: 3
  • Gracias recibidas: 682
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

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Última Edición: Post by tihana.krivic.

Age Calcualtion 10 meses 3 semanas antes #261015

  • Autor del tema
  • papin0
  • Fuera de línea
  • Expert Breezer
  • Expert Breezer
  • Mensajes: 208
  • Gracias recibidas: 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

Adjuntos:

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Última Edición: Post by papin0.

Age Calcualtion 10 meses 3 semanas antes #261022

  • Avatar de Mirec
  • Mirec
  • Fuera de línea
  • Ultimate Breezer
  • Ultimate Breezer
  • Mensajes: 2498
  • Karma: 2
  • Gracias recibidas: 135
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

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Última Edición: Post by Mirec.

Age Calcualtion 10 meses 3 semanas antes #261028

  • Autor del tema
  • papin0
  • Fuera de línea
  • Expert Breezer
  • Expert Breezer
  • Mensajes: 208
  • Gracias recibidas: 0
when I clear the date field the Age field keeps the value

Adjuntos:

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Age Calcualtion 10 meses 3 semanas antes #261035

  • Avatar de tihana.krivic
  • tihana.krivic
  • Fuera de línea
  • Moderator
  • Moderator
  • Mensajes: 10135
  • Karma: 3
  • Gracias recibidas: 682
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

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Moderadores: ForumSupport
Tiempo de carga de la página: 0.133 segundos