November 19, 200421 yr Hi all -- I have a script (thanks Garry!) that calculates today's date and formats it MM/DD/YYYY. I have placed it after <HEAD>: <script> Today = new Date(); var sTodayDate = (Today.getMonth() + 1) + "/" + Today.getDate() + "/" + Today.getFullYear(); </script> I want to use the variable "sTodayDate" in performing searches so that outdated records are not pulled. For instance: <form method=post action="FMPro" <input type=hidden name="-find"> <input type=hidden name="-db" value="DesignCalendarDB.fp5"> <input type=hidden name="-format" value="onthecalendar.html"> <input type=hidden name="-op" value="gte"> <input type=hidden name="End Date" value="sTodayDate"> <input type=hidden name="-op" value="cn"> <p class="style26"><span class="style22">Search By Event Name: <input type="text" name="Event Name"> <input type=hidden name="-max" value="10"> <input type=hidden name="-sortfield" value="Start Date"> <input type=hidden name="-sortorder" value="ascend"> <input type="submit" name="-find" value="Find Events"> <input type=hidden name="-error" value="noresultsfound.html"> </span></p> </form> In this piece of code, however, the inclusion of the variable "sTodayDate" does not work. The code works fine if I manually substitute "11/19/2004". How do I plug in the variable so this works? Thanks, friends.
November 19, 200421 yr Rob, A couple of methods exist to do this. One is to insert the value, via Javascript, when the Form is submitted. The second is to insert the while the page is being loaded. Here is the "insertion while loading" method: <form method=post action="FMPro" <input type=hidden name="-find"> <input type=hidden name="-db" value="DesignCalendarDB.fp5"> <input type=hidden name="-format" value="onthecalendar.html"> <input type=hidden name="-op" value="gte"> <script> Today = new Date(); var sTodayDate = (Today.getMonth() + 1) + "/" + Today.getDate() + "/" + Today.getFullYear(); document.write('<input type=hidden name="End Date" value="' + sTodayDate + '">'); </script> <input type=hidden name="-op" value="cn"> <p class="style26"><span class="style22">Search By Event Name: <input type="text" name="Event Name"> <input type=hidden name="-max" value="10"> <input type=hidden name="-sortfield" value="Start Date"> <input type=hidden name="-sortorder" value="ascend"> <input type="submit" name="-find" value="Find Events"> <input type=hidden name="-error" value="noresultsfound.html"> </span></p> </form> Good Luck. Garry
November 20, 200421 yr Author Garry is the Cavalry! Your solution is perfect as usual. Best, and thanks once again, Rob
Create an account or sign in to comment