ShelleyK Posted May 9, 2016 Report Share Posted May 9, 2016 Sorry to bring up an old topic but I cannot get a script to update fields. I need the Expiration field to update by one year when they click on the update button in the update single record form. Thanks. Quote Link to comment Share on other sites More sharing options...
MayMusic Posted May 10, 2016 Report Share Posted May 10, 2016 <script> function f_date(){ var expireDate=document.getElementById('EditRecordDATEFIELDNAME').value; var v_assignDate = (expireDate.getMonth() + 1) + "/" + expireDate.getDate() + "/" + (expireDate.getFullYear()+1); document.getElementById('EditRecordDATEFIELDNAME').value = v_assignDate; } f_date(); </script> try the code above in the Footer of your update page. "EditRecordDATEFIELDNAME" needs to be replaced with ID of date field. aam82 1 Quote Link to comment Share on other sites More sharing options...
ShelleyK Posted May 23, 2016 Author Report Share Posted May 23, 2016 I have tried this but it has not updated the Expiration date field on submit. Quote Link to comment Share on other sites More sharing options...
MayMusic Posted May 23, 2016 Report Share Posted May 23, 2016 To call the function on submit you need to change f_date(); to document.getElementById('caspioform').onsubmit = f_date; Quote Link to comment Share on other sites More sharing options...
ShelleyK Posted June 6, 2016 Author Report Share Posted June 6, 2016 I have tried the script above and change the f_date(); to the suggest script above. I still am having no luck in it changing the date. The field is called Expiration and it has the current expiration date in the field and I am trying to change that date on submit with a single record update datapage. I have tried this with the Expiration date hidden and display only. Neither works. What am I overlooking? Quote Link to comment Share on other sites More sharing options...
MayMusic Posted June 6, 2016 Report Share Posted June 6, 2016 Is the field you have expiration date on display only? Please make sure it is not display only Quote Link to comment Share on other sites More sharing options...
ShelleyK Posted June 9, 2016 Author Report Share Posted June 9, 2016 It is current just a text field since hidden and display only did not work. I am still having no luck in getting it to update the expiration field for the record. Quote Link to comment Share on other sites More sharing options...
ShelleyK Posted June 13, 2016 Author Report Share Posted June 13, 2016 This is the script being used. The Expiration Field is set as text and has the current expiration date in it 7/31/2018. I need to have it change to 7/31/2019 <script> function f_date(){ var expireDate=document.getElementById('EditRecordExpiration').value; var v_assignDate = (expireDate.getMonth() + 1) + "/" + expireDate.getDate() + "/" + (expireDate.getFullYear()+1); document.getElementById('EditRecordExpiration').value = v_assignDate; } document.getElementById('caspioform').onsubmit = f_date; </script> Quote Link to comment Share on other sites More sharing options...
MayMusic Posted June 14, 2016 Report Share Posted June 14, 2016 It is because " expireDate " is not defined as a date value. Try the following code: <script> function f_date(){ var date=document.getElementById('EditRecordExpiration').value; var expireDate = new Date(Date.parse(date)); var v_assignDate = (expireDate.getMonth() + 1) + "/" + expireDate.getDate() + "/" + (expireDate.getFullYear()+1); document.getElementById('EditRecordExpiration').value = v_assignDate; } document.getElementById('caspioform').onsubmit = f_date; </script> Quote Link to comment Share on other sites More sharing options...
ShelleyK Posted June 15, 2016 Author Report Share Posted June 15, 2016 Thanks. This worked Quote Link to comment Share on other sites More sharing options...
MayMusic Posted June 15, 2016 Report Share Posted June 15, 2016 Great 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.