Jump to content
ShelleyK

Expiration Field Update

Recommended Posts

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.

 

 

 

 

Share this post


Link to post
Share on other sites
<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.

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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>

Share this post


Link to post
Share on other sites

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> 

 

 

 

 

Share this post


Link to post
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
Reply to this topic...

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

×
×
  • Create New...