tbourgeois Posted May 26, 2016 Report Share Posted May 26, 2016 Hello, I am trying to edit the Java Script in the footer of a Submission Form to allow me to Concatenate Two separate Date/Time Fields. The first is a "Trip Start Date and Time" and the Second is a "Trip End Date and Time" as shown in the following attachment: The issue I'm having is that I can make one operate correctly when alone in the footer but not when I add the second. It was suggested to me that the issue may lie in the "getElementById" function and having it "defined twice" and that one may be overwriting the other. Attached are two snips of the code I have in the footer: , I need to accomplish this in a Gallery Report Data Page as well. Any thoughts? Thank you, Tyler Quote Link to comment Share on other sites More sharing options...
MayMusic Posted June 1, 2016 Report Share Posted June 1, 2016 You need to combine your scripts and have different parameter name for instance: <script> document.getElementById('Submit').onmouseover = function(){ var date = document.getElementById('cbParamVirtual1').value; if(date == "") date = "1/1/2011"; var hour = parseFloat(document.getElementById('cbParamVirtual2').value) + parseFloat(document.getElementById('cbParamVirtual5').value); if(hour =="24") hour="12"; else if(hour =="12") hour="00"; var minute = document.getElementById('cbParamVirtual3').value; if(minute == "") minute = "00"; var second = document.getElementById('cbParamVirtual4').value; if(second == "") second = "00"; document.getElementById('InsertRecordDate_Field').value = date + " " + hour +":"+ minute +":"+second; var date2 = document.getElementById('XXXXXXX').value; if(date2 == "") date2 = "1/1/2011"; var hour2 = parseFloat(document.getElementById('YYYYYYY').value) + parseFloat(document.getElementById('ZZZZZZ').value); if(hour2 =="24") hour2="12"; else if(hour2 =="12") hour2="00"; var minute2 = document.getElementById('DDDDD').value; if(minute2 == "") minute2 = "00"; var second2 = document.getElementById('TTTTTT').value; if(second2 == "") second2 = "00"; document.getElementById('BBBBBBBB').value = date2 + " " + hour2 +":"+ minute2 +":"+second2; }; </script> Make sure to replace IDs with actual IDs Quote Link to comment Share on other sites More sharing options...
tbourgeois Posted June 6, 2016 Author Report Share Posted June 6, 2016 Thank you May Music, This is what I ended up with. What do you think? .............................................................................................................................. <SCRIPT LANGUAGE="JavaScript"> document.getElementById('caspioform').onchange = function(){ //This takes the date and time and concatenates into one variable //!!! If on submission form use 'INSERT' record //!!! if on management form use 'EDIT' record // Date var dt1 = document.getElementById('cbParamVirtual1').value; var dt2 = document.getElementById('cbParamVirtual5').value; // hours var hr1 = document.getElementById('cbParamVirtual2').value; var hr2 = document.getElementById('cbParamVirtual6').value; // Minutes var mn1 = document.getElementById('cbParamVirtual3').value; var mn2 = document.getElementById('cbParamVirtual7').value; //Seconds var seconds = "00"; var ampm1 = document.getElementById('cbParamVirtual4').value; var ampm2 = document.getElementById('cbParamVirtual8').value; var dateAndTime1 = dt1 + " " + hr1 + ":" + mn1 + ":" + seconds + " " + ampm1; var dateAndTime2 = dt2 + " " + hr2 + ":" + mn2 + ":" + seconds + " " + ampm2; // First date/time field if (dt1 !== "" && hr1 !== "" && mn1 !== "" && ampm1 !== "" ) { document.getElementById('InsertRecordStart_Date_and_Time').value = dateAndTime1; } else { document.getElementById('InsertRecordStart_Date_and_Time').value = ""; } // Second date/time field if (dt2 !== "" && hr2 !== "" && mn2 !== "" && ampm2 !== "" ){ document.getElementById('InsertRecordEnd_Date_and_Time').value = dateAndTime2; } else { document.getElementById('InsertRecordEnd_Date_and_Time').value = ""; } }; </SCRIPT> ....................................................................................................................................................... Thanks, Tyler Quote Link to comment Share on other sites More sharing options...
MayMusic Posted June 6, 2016 Report Share Posted June 6, 2016 Does it work or you are getting error? You can try developer tool and console to see if you get any error on submit 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.