Jump to content

TWIRED

Caspio Ninja
  • Posts

    81
  • Joined

  • Last visited

  • Days Won

    1

Status Replies posted by TWIRED

  1. Hi,

    The purpose of a forum is to share the knowledge.

    If you have a question. Ask it on the forum. If you must, ask me to look at it and I will, but it must already be a question on the forum.

    Let's make sure we share the knowledge.

    CHAD

    1. TWIRED

      TWIRED

      That makes sense. 

       

      This question was posted but didnt get a reply so kinda got impatient

      Will do.

      Thanks~

  2. TWIRED

    TWIRED    Jan

    Hi Jan,

    Could use your help

     

    Im trying to change the text of a label.

    script below doesnt work.

    I can get the id , but unable to replace the text.

     

    What am I doing wrong?

     

    Ive also loaded it onLoad , so that the html loads before the script,

    but it doesnt work

    Thanks !!

     

     

    var label=document.getElementsByTagName('input')[0].id;
    alert("label value=" +label);
    document.getElementById('label').innerText = 'Change The Label Text';

    1. TWIRED

      TWIRED

      Update

      I have managed to change

      -the label of a virtual field

      -label of an  input field

      -value of an input field

       

      All I need now is help updating the value of a virtual field text box.

       

      Thanks !

  3. 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 ?

  4. 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. 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>

    2. (See 5 other replies to this status update)

  5. 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. 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>

    2. (See 5 other replies to this status update)

  6. 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. TWIRED

      TWIRED

      Hey Cherif...

      I had contacted support, this is what they replied.

       

      Thank you for contacting Caspio Support.

      I would recommend separating the search and report DataPage into two DataPages as found in this How-To: 
      http://howto.caspio.com/tech-tips-and-articles/tech-parameters/how-to-separate-search-page-and-results-page-into-two-different-webpages/
      or discussed in this video: http://howto.caspio.com/getting-started/display-results-on-a-separate-web-page/

      The key difference in your scenario, is the initial search (now a submission form) would use the data source where you need to submit information. You would use the actual fields for that table instead of the virtual fields as discussed in the article. You would still pass these values on exit, so that the results page can be filtered by these values. This way the submission form passes the required parameters and also submits the records, with no need for a hidden form and auto-submit.
       

    2. (See 5 other replies to this status update)

  7. 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. TWIRED

      TWIRED

      •  
      • TWIRED
      • Caspio Ninja
      •  1
      • 64 posts
      • LocationNew York

      Cherif....

      Ive given it a thought and based on what "I think  I understand"  about your setup Hopefully heres a solution.

      Goal : To Restrict User Search to Max 5  Searches within the same day ,if not a Paid subscriber.

      ----------------------------------------------------------------------------------------------------
      Your Tables and Datapages Setup
      ------------------------------------------------------------------------------------------

      Lets say you already have the following Tables created 
      1) UserInfo Table ( all your userprofile information)
      2) SearchResults Table ( a table which you are doing your searches against)

       

      Create a Parent Child Relationship

      UserInfo (One) - (Many) -SearchResults) based on UserID

       

      Add 3 fields to  the "UserInfo" table

      - LastSearchedDateTime field (datetime data type ) 

      - SearchCounted field (Number data type) << If he is permitted to search , after search increase the counter by 1

      -PaidUser ? (Yes/No) << This will have to be updated programatically (an administrator update form or entered directly into database)

      Create View "UserAuthView" and Authentication "UserAuth" based on UserInfo Table.  << This is Very Important to get the fields from UserInfo table

      Search & Report dataPage (1 single Page) - Allow users to select data using a search form
      Im assuming you have setup a SearchReports Datapage (Same Page) 
      Make the source of your "Search" DataPage  : "ADummyTable" << Justa simple one field dummy table, it does not matter.


      When a User Clicks on Search , 
      a Javascript function  will get the values of the 3 fields above , and test it to permit or not permit additional searches.


      -------------------------------
      The "Search & Report" DataPage
      ----------------------------
      Data Source = "ADummyTable"
      MUST HAVE Authentication Enabled ! << authentication will be based on >>> UserInfo Table << , from which we will get lastdatetime,searchcounter  and paiduser  fields.

      Create Virtual Fields for Your actual Search Filters.

      Place a footer and javascript in the section below for validation:
      Search and Report Wizard - Configure Search Fields

      --------------------------------------------------------------
      Pseudo JS Code in footer >>  SearchPage << 
      -----------------------------------------------------------------
      //Validate based on 24 Hours in same day , and 5 Searches Maximum


      //Get last searched date from field in table
      LastSearchedDateTimefield=(example 01/15/2017)


      //get the Searchcount from table
      Searchcountedfield=(example: 2)

      //Get PaidUser Value from table
      PaidUserfield= (example: "No")

      //Validate (Pseudo Code)

      @MaxSearchesAllowed=5;
      IF  todays date is greater than date in lastdatetime field (and paiduser=No ), get counter in table,  and set it to 1 where userid =userid >> allow access

      IF todays date is the same as the lastdatetime in lastdatetime field , then get the counter value from  table, 
      - if counter in table is under @MaxSearchesAllowed , increment counter by 1 >> allow access
      -if counter in table =  @MaxSearchesAllowed then >> deny search

      IF lastdatetime field or counter field is blank, then set to current date and counter to 1 >> allow access  (First Time User)

      IF Paid User = Yes , then >>> allow full access (log the current datetime and increase the counter 
       

       Continue to Results Page....
       

    2. (See 5 other replies to this status update)

×
×
  • Create New...