Jump to content
  • 0

Click to Timestamp


Joemac
 Share

Question

3 answers to this question

Recommended Posts

  • 1
28 minutes ago, Joemac said:

Can someone help me create a button that when clicked it timestamps a date field?  I have the start and stop fields below and my users have to key in the time and keep forgetting to add the time or remember to select AM or PM.  Thanks!

image.png.a67baf16befe279c89175d2646820c04.png

HTML BLOCKS
 

<button id="button1" type="button">Start</button>
<button id="button2" type="button">END</button>

FOOTER:

<script>
document.getElementById("button1").addEventListener("click", function tx(){

var date = new Date();

document.getElementById("InsertRecordFIELDNAME").value = date.toLocaleString("en-US").replace(',','');

document.getElementById("button1").removeEventListener("click", tx); //so button will only work once remove line if you want to keep it clickable

});

</script>


<script>
document.getElementById("button2").addEventListener("click", function tx1(){

var date = new Date();

document.getElementById("InsertRecordFIELDNAME").value = date.toLocaleString("en-US").replace(',','');

document.getElementById("button2").removeEventListener("click", tx1); //so button will only work once remove line if you want to keep it clickable

});

</script>

 

Link to comment
Share on other sites

  • 0

@TellMeWhy - thanks for taking the time to write this for me - much appreciated.  For some reason I can never add in the fields and get these to work, I cannot get the syntax down.  So just looking at the start button I'm hoping you can walk me through this.  So I'm in a Single Record Update DataPage.  The field is a date field called ink_start from the table called tbl_drops.  So when I use the field picker it looks like this [@field:tbl_drops_ink_start*] 

So based on that what would the code below look like once I added in the information I need to get this working?  I'm thinking I'm not writing the correct thing under the "InsertRecordFIELDNAME"

 

<script>
document.getElementById("button1").addEventListener("click", function tx(){

var date = new Date();

document.getElementById("InsertRecordFIELDNAME").value = date.toLocaleString("en-US").replace(',','');

document.getElementById("button1").removeEventListener("click", tx);

});

</script>.  
Link to comment
Share on other sites

  • 0
On 8/21/2021 at 8:07 AM, Joemac said:

@TellMeWhy - thanks for taking the time to write this for me - much appreciated.  For some reason I can never add in the fields and get these to work, I cannot get the syntax down.  So just looking at the start button I'm hoping you can walk me through this.  So I'm in a Single Record Update DataPage.  The field is a date field called ink_start from the table called tbl_drops.  So when I use the field picker it looks like this [@field:tbl_drops_ink_start*] 

So based on that what would the code below look like once I added in the information I need to get this working?  I'm thinking I'm not writing the correct thing under the "InsertRecordFIELDNAME"

 

<script>
document.getElementById("button1").addEventListener("click", function tx(){

var date = new Date();

document.getElementById("InsertRecordFIELDNAME").value = date.toLocaleString("en-US").replace(',','');

document.getElementById("button1").removeEventListener("click", tx);

});

</script>.  

It should be EditRecord then instead of InsertRecord

 

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
Answer this question...

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

×
×
  • Create New...