Forums

Put an AND statement into a Sshow Parent event

arrick 01 Jul, 2015
I need to setup some AND statements into some events, and am now sure how to do it... I know it will have to be something custom.

Psuedo code below:


if (appGender = '0' && appAgeAtApp < '17') {
    show parent of appSelServ;
}
GreyHead 03 Jul, 2015
1 Likes
Hi moorear,

I don't think that you can do this using the built-in events beyond using them to call a function when the element changes. I got a simple version of this working with this function
function showBox() {
  if ( jQuery('input[name=appGender]:checked').val() == 'm' && parseInt(jQuery('#appAgeAtApp').val()) <= 17 ) {
   jQuery('#form-row-appSelServ').show();
  } else {
   jQuery('#form-row-appSelServ').hide();
  }
}
Note that I changed the gender radio to use m & f instead of 0 and 1 as 0 can cause problems. The function is called on Change of the gender buttons and on Typing for the age text input,

You would probably want to extend this to check that an age has been entered.

Bob
arrick 08 Jul, 2015
Hey Bob, can you give a little bit more information on exactly how you set this up, so I can use it as a template and learn from it? Where do I call the function, etc?
GreyHead 08 Jul, 2015
Answer
1 Likes
Hi moorear,

You put the function in a Load JavaScript action in the form On Load event - move it up before the HTML (Render Form) action.

Then in the Designer tab click the Events sub-tab and drag across a Function Call event - probably two of them. You can configure this to run the showBox function when the apppGender and appAgeAtApp elements change/are edited.

Bob
arrick 09 Jul, 2015
1 Likes
Thank you Bob, it all works.
This topic is locked and no more replies can be posted.