Datepicker Issues

I am trying to get a specific element to show when selecting a specific date in a datepicker. I am a novice when it comes to this sadly so any help is greatly appreciated.

Hey
look at the onChange event and result you get when reading out the .value onChanged. You will get the selected date and by using If Else statements you will control if it matches. Then use show to display elements.

thanks for the reply, as mentioned i am a novice so not sure how to write this exactly.

for example, if i chose 01/01/2019 from the datepicker it then displays element a & element b, how would this be written?

@planmytrip

Don’t know if this is working 100%, just writing it from the docs.

$w("#myDatePickerId").onChange( (event, $w) => {
  let newValue = event.target.value;  // "01/01/2019"
  if (newValue.includes("04/02/2019")) {
    $w("#elementa").show();
    $w("#elementb").show();
  } else {
     $w("#elementa").hide(); 
     $w("#elementb").hide(); 
  }
});

@andreas-kviby thanks Andreas, i can see what it is trying to do but still does not like it for some reason :(. It does not seem to like the ‘if (newValue.includes(“04/02/2019”))’ statement

this does not work still, can someone please help me :frowning:

Try let newValue = event.target.value.toString()

@andreas-kviby Hi Andreas, thnaks again for the response. However it still wont work, i dont know what to do :frowning: My code is currently as follows;

$w(“#sanfrandatepick”).onChange( (event, $w) => {
let newValue = event.target.value.toString(); // “01/01/2019”
if (newValue.includes(“04/02/2019”)) {
$w(“#vectorImage6”).show();
} else {
$w(“#vectorImage6”).hide();
}
});

@andreas-kviby i managed to get this almost working, i can get the image to show but not to hide? is there anything i need to change.