Jump to content

Timestamp on a change event in a Dropdown menu


Recommended Posts

Hello,

I have a details page with an update button where I would like to be able to update the value of a Text Field with the current date whenever a user changes the value of an option in a Dropdown menu and clicks update.

The code below below is not working. Any help will be very much appreciated.

Thank You.

function getT()

{

document.getElementById("EditRecordpatient_status").onchange == document.getElementById("EditRecordpatient_status_change_timestamp").value = '[@cb:Timestamp]';

}

document.getElementById("Mod0EditRecord").onclick=getT;

Link to comment
Share on other sites

  • 1 year later...
  • 5 months later...
  • 4 years later...
  • 4 weeks later...

Hi,

 

As I understood OP's inquiry, I think they wanted to submit the timestamp of the most recent update to the Dropdown, and not when the DataPage actually loaded.

 

Looking at the answers above, what the solutions do is assign '[@cbTimestamp]' to EditRecordpatient_status_change_timestamp everytime EditRecordpatient_status is updated.

Do note, though that [@cbTimestamp] is a STATIC value once the DataPage has been rendered. Meaning, it's value is the current timestamp when the DataPage is loaded. It does not change after then, even if the HTML 'change' event is emitted.

 

The answer to the original question would be:

<script>

  var dropdown = document.querySelector('[id*=EditRecordpatient_status]')
  var tstamp = document.querySelector('[id*=EditRecordpatient_status_change_timestamp]')
  
  dropdown.onchange = function() {
    var dt = new Date();
    tstamp.value = `${dt.toLocaleDateString()} ${dt.toLocaleTimeString()}`
  }

</script>

 

Cheers!

DN31337

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