AnsweredAssumed Answered

Show a panel based on conditions I'm checking in the form's Custom JavaScript

Question asked by mindymac03 on May 17, 2017
Latest reply on May 19, 2017 by jpmhuls

Hello. I am using the form's Custom JavaScript section to check the date/time (we have a service at my hospital that is available certain days/times). I have that js working fine and I end up with a true or false. If true, I want to show panelA. If false, I want to show panelB. I am having trouble with the syntax.

 

  [if IE 9]  [endif] 

NWF$(document).ready(function() {

 

var dt = new Date();
var w = dt.getDay();
var h = dt.getHours();
var m = dt.getMinutes();
var isAvailable = false;

if (w === 1 || w === 2 || w === 3 || w === 4 || w === 5) {  /* is time b/t 9:45 and 4:45? */
  if (h >= 9 && h <= 15) {
    isAvailable = true;
  } else if (h === 16 && h <= 45) {
    isAvailable = true;
  }
} else {
  /*not available on weekends*/
  isAvailable = false;
}
window.alert(isAvailable);
 
});
I want to use the isAvailable boolean to show panelA or panelB and am not getting the syntax right. Can anyone help?

Outcomes