Jump to content

Is It Possible To Search By Entered Date + N Days?


Recommended Posts

Hi Cameron,

 

You can follow the steps:

  1. On the Search screen, select the date field, click "add a field", select "New Criteria".
  2. Select the field again, in the "Logical operator between criteria" field, select "AND".
  3. Select Criteria 1, in the "Comparison type",  select "Greater than or equal".
  4. Select Criteria 2, in the "Form element" field, select "Hidden"; in the "Comparison type",  select "Greater than or equal".
  5. Add the Header&Footer element, select Footer, click the Source button or disable HTML Editor and enter the following code:
<SCRIPT LANGUAGE="JavaScript">
function setDate()
{
    number_of_the_field = 1;
    numberDays = 7;

    var fieldname1 = "Value"+number_of_the_field+"_1";
    var fieldname2 = "Value"+number_of_the_field+"_2";

     var stringDate = document.getElementById(fieldname1).value;
     var myDate = new Date(Date.parse(stringDate));
     myDate.setDate(myDate.getDate()+numberDays);
     var myMonth = myDate.getMonth() + 1;
     if (myMonth<10) {myMonth = "0" + myMonth;}
     var myDay = myDate.getDate();
     if (myDay<10) {myDay = "0" + myDay;}
     var myYear = myDate.getFullYear();
     var result = myMonth + "/" +  myDay + "/" + myYear;
     document.getElementById(fieldname2).value=result;
}   

document.getElementById("caspioform").onsubmit=setDate;
</SCRIPT>

number_of_the_field - is the order number of the field on the page. If it's the first page, than enter "1".
numberDays - enter the number of days that should be added.

 

I hope, it helps.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...