perland Posted March 10, 2012 Report Share Posted March 10, 2012 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; Anthonyjulk 1 Quote Link to comment Share on other sites More sharing options...
nkamalan Posted March 13, 2012 Report Share Posted March 13, 2012 Please try this in the footer of the page: function getT() { document.getElementById("EditRecordpatient_status_change_timestamp").value = '[@cbTimestamp]'; } document.getElementById('EditRecordpatient_status').setAttribute("onChange", "getT();"); Regards, NKamalan Quote Link to comment Share on other sites More sharing options...
nkamalan Posted March 13, 2012 Report Share Posted March 13, 2012 You can also try this: function f_change() { document.getElementById("TextBoxID").value="[@cbTimestamp]"; } document.getElementById("DropdownID").onchange=f_change; Quote Link to comment Share on other sites More sharing options...
Jomiller Posted March 14, 2012 Report Share Posted March 14, 2012 • The clarity in your post is simply spectacular and i can assume you are an expert on this field. Thanks a million and please keep up the fabulous work. Quote Link to comment Share on other sites More sharing options...
perland Posted March 14, 2012 Author Report Share Posted March 14, 2012 Thank you nkamalan. I used the first code and it does exactly what I needed. Thanks again. Quote Link to comment Share on other sites More sharing options...
mpnewby Posted January 4, 2014 Report Share Posted January 4, 2014 Why can't I see the solution here? I am logged in. Thanks. Quote Link to comment Share on other sites More sharing options...
Ovidium Posted June 10, 2014 Report Share Posted June 10, 2014 anyone can see the solution here? Quote Link to comment Share on other sites More sharing options...
casGary Posted June 10, 2014 Report Share Posted June 10, 2014 <script> function getT() { document.getElementById("EditRecordpatient_status_change_timestamp").value = '[@cbTimestamp]' } document.getElementById('EditRecordpatient_status').setAttribute("onChange", "getT();"); </script> It should be visible now Ovidium 1 Quote Link to comment Share on other sites More sharing options...
Kurumi Posted March 4, 2019 Report Share Posted March 4, 2019 You could use the option 'Stamp on Update' on your Timestamp data type. Just like this: For more information about Data Types, check the article here: https://howto.caspio.com/tables-and-views/data-types/ I hope this helps! Quote Link to comment Share on other sites More sharing options...
DefinitelyNot31337 Posted April 1, 2019 Report Share Posted April 1, 2019 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.