Jump to content

How to run script on change only


Recommended Posts

The code below works fine when someone changes the default value from No to Yes in my 'DispoToday' field. My challenge is when the record already has a value of Yes and someone updates another field then the script will update the date again. I only want the date to write out the first time someone changes the 'DispoToday' from No to Yes.

<script type= "text/javascript">
function getT() {
  if(document.getElementById("EditRecordDispoToday").value == 'Yes') {
    document.getElementById("EditRecordTimeofView").value = '[@cb:Timestamp]';
  }
}

document.getElementById("caspioform").onsubmit = getT;
</script>

 

Link to comment
Share on other sites

On 1/19/2017 at 7:29 PM, UltraSrc said:

The code below works fine when someone changes the default value from No to Yes in my 'DispoToday' field. My challenge is when the record already has a value of Yes and someone updates another field then the script will update the date again. I only want the date to write out the first time someone changes the 'DispoToday' from No to Yes.

<script type= "text/javascript">
function getT() {
  if(document.getElementById("EditRecordDispoToday").value == 'Yes') {
    document.getElementById("EditRecordTimeofView").value = '[@cb:Timestamp]';
  }
}

document.getElementById("caspioform").onsubmit = getT;
</script>

 

Try changing the last line of code. Use:

document.getElementById("EditRecordDispoToday").onchange = getT;

instead of:

document.getElementById("caspioform").onsubmit = getT;

Another option is to create a rule. The rule will be: when DispoToday field equal to Yes - make TimeofView field display only

Hope that helps :)

Cheers!

Link to comment
Share on other sites

On 1/26/2017 at 3:04 AM, Mathilda said:

Try changing the last line of code. Use:

document.getElementById("EditRecordDispoToday").onchange = getT;

instead of:

document.getElementById("caspioform").onsubmit = getT;

Another option is to create a rule. The rule will be: when DispoToday field equal to Yes - make TimeofView field display only

Hope that helps :)

Cheers!

Thank you - changing the last line of the code has worked out. Much appreciated it.

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