Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 7386 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I have a datebase of events that contain a "Start Date" and an "End Date" field. I want web users to see all events running for the current week, i.e., from today's date and for one week thereafter. At the moment I have to hard code individual dates. For instance, if I wanted to pull up events for the week beginning 8/1/2004, I'd have to put a link in like this:

<a href="FMPro?-db=DesignCalendarDB.fp5&-format=onthecalendar.html&-op=lte&Start%20Date=8/7/2004&-op=gte&End%20Date=8/1/2004&-find">

1. Is there any way to write this link so that it automatically uses today's date for this calculation (i.e., substitutes today's date for the "End Date" field in the above link

2. Can it calculate the value for the "Start Date" field above automatically, which will be today's date plus six days?

I know FMP needs to "process" this, which is why I have it as a link. Ideally, however, I'd like the current week's events to pull up automatically. Ideas? A meta refresh or something like that?

Lastly, basing a find on "currentdate" does not seem to work with FMP since currentdate returns a 2 digit year whereas FMP records dates with 4-digit years.

Thanks gang!

Rob

Posted

You could have this bit of Javascript in the <head>:

<script>

Today = new Date();

var sTodayDate = Today.getDate() + "/" + (Today.getMonth() + 1) + "/" + Today.getFullYear();

NextDate = new Date(Date.parse(Today) + (86400000 * 6));

var sNextDate = NextDate.getDate() + "/" + (NextDate.getMonth() + 1) + "/" + NextDate.getFullYear();

</script>

</head>


You can then use it like this:


<script>document.write("<a href='FMPro?-db=mydb.fp5&-format=mypage.html&-op=lte&Start%20Date=" + sNextDate + "&-op=gte&End%20Date=" + sTodayDate + "&-findall");</script>

The logic of the request may need to be changed however I hope this is helpful.

Good Luck.

Garry

Posted

Thanks, Garry! Let me play around with it, and I'll let you know. In the meantime, where can I send the case of wine . . . ?

Posted

Garry -- I played with your syntax a little bit and I wound up turning it into a single script that I dropped into a markup item. It works fine, but as a link:

<script>

Today = new Date();

var sTodayDate = (Today.getMonth() + 1) + "/" + Today.getDate() + "/" + Today.getFullYear();

NextDate = new Date(Date.parse(Today) + (86400000 * 10));

var sNextDate = (NextDate.getMonth() + 1) + "/" + NextDate.getDate() + "/" + NextDate.getFullYear();

document.write('<a href="FMPro?-db=DesignCalendarDB.fp5&-format=newhome.html&-sortfield=Start%20Date&-sortorder=ascend&-op=lte&Start%20Date=' + sNextDate + '&-op=gte&End%20Date=' + sTodayDate + '&-op=neq&Event%20Type=Exhibit&-error=newhome.html&-find"><p class="style17"><span class="style16">Press Me!</span></p></a>');

</script>

While this script works as a link, I need it to run automatically on my home page. Is there a way to put this whole script in the head and use a meta refresh tag or something so that every time the home page loads the script runs this search and displays the results?

Best, RR

Posted

You can use an "onload=" in the <body> tag. This can call "newhome.html". For example:

<html><head><script>

Today = new Date();

var sTodayDate = (Today.getMonth() + 1) + "/" + Today.getDate() + "/" + Today.getFullYear();

NextDate = new Date(Date.parse(Today) + (86400000 * 10));

var sNextDate = (NextDate.getMonth() + 1) + "/" + NextDate.getDate() + "/" + NextDate.getFullYear();

</script></head>


Then:



<body onload="document.location='FMPro?-db=DesignCalendarDB.fp5&-format=newhome.html&-sortfield=Start%20Date&-sortorder=ascend&-op=lte&Start%20Date=' + sNextDate + '&-op=gte&End%20Date=' + sTodayDate + '&-op=neq&Event%20Type=Exhibit&-error=newhome.html&-find';">

Loading...</body></html>

Good Luck.

Garry

This topic is 7386 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.