Andrii Posted August 20, 2018 Report Share Posted August 20, 2018 To add timestamp depending on the presence of File in the File input field you need to add one additional HTML field and insert this snippet of code: <script type="text/javascript">function addTimestamp (fileInputId, timestampInputId) { var fileInput = document.getElementById(fileInputId); fileInput.addEventListener('change', function () { if (fileInput.files.length !== 0 ){ document.getElementById(timestampInputId).value = '[@cbTimestamp*]'; } }); }; addTimestamp('File_Id_1', 'Date_Input_Id_1'); addTimestamp('File_Id_2', 'Date_Input_Id_2'); addTimestamp('File_Id_3', 'Date_Input_Id_3'); . . . addTimestamp('File_Id_X', 'Date_Input_Id_X'); </script> fileInputId: ID of the File field timestampInputId: ID of the Date Field You can add as many functions depending on the number of your file fields. To find the ID of fields use Developer tools and "Inspect" NOTE! You need to use the proper type of short date to save the value. Example - 20/08/2018; dd/MM/ yyy Quote Link to comment Share on other sites More sharing options...
edujobs2k18 Posted August 28, 2018 Report Share Posted August 28, 2018 What if i wanted to put timestamp and text in two different filed? Like if user uploaded a file in "Field_ID_1" and automatically timestamp will be inputed in "Date_Input_ID_1" and automatically a text "New" will be inputted in a field "Remarks_ID_1". what will be the script in there to use? Quote Link to comment Share on other sites More sharing options...
Andrii Posted August 29, 2018 Author Report Share Posted August 29, 2018 @edujobs2k18 To implement your workflow you can use this code: <script type="text/javascript">function addTimestamp (fileInputId, timestampInputId, textInptId) { var fileInput = document.getElementById(fileInputId); fileInput.addEventListener('change', function () { if (fileInput.files.length !== 0 ){ document.getElementById(timestampInputId).value = '[@cbTimestamp*]'; document.getElementById(textInptId).value = 'New'; } }); }; addTimestamp('fileInputId1', 'timestampInputId1', 'textInptId1'); addTimestamp('fileInputId2', 'timestampInputId2', 'textInptId2'); addTimestamp('fileInputId3', 'timestampInputId3', 'textInptId3'); . . . addTimestamp('fileInputId_x', 'timestampInputId_x', 'textInptId_x'); </script> Just find the IDs of the text fields using Developer Tools of the browser and insert these values instead of 'textInputId1', 'textInputId2'.....'textInputId_x'. 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.