Auto populate datetimestamp and username if adding notes to cell
Auto populate datetimestamp and username if adding notes to cell
Running Editor 1.9.4 using AutoFill/Keys. I was wonder if there a way to auto populate a date timestamp and username in a cell when a user clicks into a specific editable cell to add notes/comments. For example, when a user double clicks into "Note" cell (AutoFill/Keys) it generates today's date timestamp along with their username. The user would then only need to add their note/comment. Or if the user clicks on the edit button and then clicks into the "Note" input field which then triggers the same auto date timestamp/ username?
This question has accepted answers - jump to:
This discussion has been closed.
Answers
If the timestamp is always NOW(), just let the database take care of it. It needn't appear on the table at all. Alternatively, give it a read-only default value equal to NOW().
Regarding the user id, are you keeping track of users in the session?
@tangerine yep PHP Session, only problem is this field can be alter once or multiple times and we want to keep all timestamps. For Example:
11/01/2020 [username] Note 1
11/02/2020 [username] Note 2
11/07/2020 [username] Note 3
This example from this thread should help. It's showing how to change a cell's value when editing starts.
Colin
@colin Thanks for the example link, I've got it working partially, only when I select the first column, hit the edit button, and make changes, then hit the update button will it persist the changes. However, using AutoFill/Key it will not persist the changes to the database. This is the js I've added:
What else am I missing?
@colin Looks like I found the solution, I've tested it a handful of times, but I removed this portion of the code:
And I've been able to save edits both via edit buttons or using AutoFill/Key on the two editable fields
Excellent, thanks for reporting back,
Colin