Jump to content

Cherif

Members
  • Content Count

    5
  • Joined

  • Last visited

  1. Hey there!

     

    Thanks a lot for your reply on my  Limit the number of search by user?  post.

     

    Just a quick question. When you say:

     

    ==

    Every time a FreeUser logs in:

    - stamp the datetime in the "logindatetime" field.

     

    Everytime a FreeUser completes a search 

    -Increase the SearchCount with an increment of 1

     

    ==

     

    Do you mean that I have to do it manually everytime? Is there no way for it to be done automatically ?

    1. Show previous comments  3 more
    2. TWIRED

      TWIRED

      In the first Search submission page,

      you would have  a script - something like this in the footer

      -------------------------------------------------------------------------------------

      <script>

      var maxsearchesallowed=5;


      var searchdate=[@authfield:A1_DUMMY_USER_AUTH_INFO_TABLE_DummyUserSearchDate*];

      var counter=0;
      var counter="[@authfield:A1_DUMMY_USER_AUTH_INFO_TABLE_DummyCount#]";

      var paiduser="[@authfield:A1_DUMMY_USER_AUTH_INFO_TABLE_DummyPaidUser]";

      var today = new Date();
      //alert(today);
      var dd = today.getDate();
      //alert("todays date= " + dd);
      var mm = today.getMonth()+1; //January is 0!
      //alert("todays month= " + mm);

      var yyyy = today.getFullYear();
      if(dd<10){
          dd='0'+dd;

      if(mm<10){
          mm='0'+mm;

      var today = mm+'/'+dd+'/'+yyyy;

      today=new Date(today);
      searchdate=new Date(searchdate);

      counter=Number(counter)+1;

      //alert("received today= " +today);
      //alert("counter=" + counter);
      //alert("received searchdate= " +searchdate);

       

      function checkvalid() {

      if((today > searchdate) && (paiduser=="No" && Number(counter) < Number(maxsearchesallowed) ) )
      {
      alert("allow to search");


      document.getElementById("[@authfield:A1_DUMMY_USER_AUTH_INFO_TABLE_DummyUserSearchDate*]").value=today;

      document.getElementById("[@authfield:A1_DUMMY_USER_AUTH_INFO_TABLE_DummyCount#]").value=counter;
      //alert("counter="+counter);

      else
      {
      alert("sorry, you have exceeded your quota!");
      window.location("REDIRECT_URL_to_Anotherpage.html");
      return false;
      }
      }

      checkvalid();
      </script>

    3. TWIRED

      TWIRED

      Updated code that works...

      based on setup

       

      <script>

      var maxsearchesallowed=5;

      var counter=0;
      var counter="[@field:DummyCount#]";

      var paiduser="[@authfield:A1_DUMMY_USER_AUTH_INFO_TABLE_DummyPaidUser]";
      alert("paiduser= "+paiduser);

      //----------------------today date format---

      var today = new Date();
      //alert(today);
      var dd = today.getDate();
      //alert("todays date= " + dd);
      var mm = today.getMonth()+1; //January is 0!
      //alert("todays month= " + mm);

      var yyyy = today.getFullYear();
      if(dd<10){
          dd='0'+dd;

      if(mm<10){
          mm='0'+mm;

      var today = mm+'/'+dd+'/'+yyyy;

      //today=new Date(today);

      var searchdate=document.getElementById("EditRecordDummyUserSearchDate").value;

      alert("today=  "+today);
      alert("searchdate= " + searchdate);


      //test
      //today=searchdate;

      function myFunction() 
      {
      if((today => searchdate) && (paiduser=="No" && Number(counter) < Number(maxsearchesallowed) ) )
      {
      alert("allow to search");
      document.getElementById("EditRecordDummyUserSearchDate").value=today;

      //counter=Number(counter)+1;
      document.getElementById("EditRecordDummyCount").value=Number(counter)+1;
      //alert("counter="+counter);

      else
      {
      alert("sorry, you have exceeded your quota!");
      window.location("http://www.tripatwork.com/sa-test-pages---2.html");

      }
      }
      document.getElementById("caspioform").onsubmit=myFunction; 

      </script>

    4. TWIRED

      TWIRED

      Heres a working model that works

       

      http://www.tripatwork.com/test-searchsubmit-page.html

       

      user: cherif@cherif.com

      pass : cherif

×
×
  • Create New...