Click to See Complete Forum and Search --> : code for 'between'


fritzmaas
11-15-2004, 11:08 AM
I am trying to write a code, which recognizes values between two variables, i.e. arrivaldate and departuredate. arrivaldate can be anything between 1 and 31 and so can departuredate. My problem is how do I write a code for the dates between, for example arivaldate is 2 and departuredate is 5.
Any help to a javascript novice would be greatly appreciated.

F Maas

Juuitchan
11-15-2004, 11:13 AM
What do you mean, "write code for the dates between"? What do you want to do with these dates? You've given us a noun but no verb. Now please give us the verb.

icreal
11-15-2004, 11:33 AM
<script language="JavaScript">
arrivaldate = 5;
departuredate = 8;
comparedate = 9;

if ((comparedate >= arrivaldate) && (comparedate <= departuredate))
{alert("within dates");}
else
{alert("outside dates");}
</script>