Jump to content

How Do I Timestamp A Record When Value Of A Checkbox Is Changed?


Recommended Posts

Place the script below in the Footer of your details/update page.

Status is my checkbox field. Change Status in the code to your field name.

Time_status_edited is a hidden field to store the timestamp. Change Time_status_edited to your field name.

---------------------------------------------------------------
function getT()
{
var prevValue='[@field:Status]';

if(((prevValue!= 'Yes') && (document.getElementById("EditRecordStatus").checked)) || ((prevValue== 'Yes') && (!document.getElementById("EditRecordStatus").checked)))

 {
   document.getElementById("EditRecordTime_status_edited").value = '[@cb:Timestamp]';
  }
}
document.getElementById("caspioform").onsubmit = getT;

</script>
 

Link to comment
Share on other sites

Hi Barbara,

 

Please do not forget the "<script>" before the code.

The whole code will be:

 

<script>

function getT()
{
var prevValue='[@field:Status]';

if(((prevValue!= 'Yes') && (document.getElementById("EditRecordStatus").checked)) || ((prevValue== 'Yes') && (!document.getElementById("EditRecordStatus").checked)))

 {
   document.getElementById("EditRecordTime_status_edited").value = '[@cb:Timestamp]';
  }
}
document.getElementById("caspioform").onsubmit = getT;

</script>
Link to comment
Share on other sites

  • 4 years later...

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