Jump to content

How to run a script on change only - 2


Recommended Posts

Hi there,

I have 2 tables that I'm passing parameters between using a redirect and auto-submit.

In the datapage, the user can assign a star rating which is updated in the main table.  I wish to pass that parameter to my second table (via the redirect / auto-submit) ONLY if it has changed ...

At the moment, the field is called "QA_Tester_Rating" in both tables and it is passing fine from the redirect etc to the 2nd table.  Do I want to set up a script in my first datapage or second, to look for changes in the field and only pass the figure if it has changed?  I want the field to be blank in my table if there are no changes.

Any help much appreciated!

Nikki

 

 

 

Link to comment
Share on other sites

  • 1 month later...

Is the first page details page? If yes you can add a calculated field to read the value of the rating and see if the new one is different.

If not, in the second page receive the parameter in a variable first and also create another variable to compare these two values. If it if not the same then save the new one.

<script>
var current = document.getElementById('QA_Tester_Rating').value;
var newvalue = '[@parametername]';
 
  if ( current != newvalue){
    document.getElementById('QA_Tester_Rating').value = newvalue; 
    f_Submit ();
      
      } else {
      f_Submit (); 
      }
     
      function f_Submit (){
   setTimeout('document.forms["caspioform"].submit()',1000); 
  }
</script>

 

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