Greetings,
I'm trying to figure out how to reset, or clear a field in the detail view after saving changes. For example; I have a field with a default of 0.00 and I put 2.00 in and use that in a calculated field, but then I need to reset the 2.00 back to 0.00 after saving changes.
Thank you,
David
Reset, or clear field after save changes
-
- Veteran Member
- Posts: 101
- Joined: 2019-05-26 18:38
Re: Reset, or clear field after save changes
Hi,
can you explain why you need to do so? This would change your dataset and once you save the changes you will overwrite the data for that field and the calculated field again.
can you explain why you need to do so? This would change your dataset and once you save the changes you will overwrite the data for that field and the calculated field again.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
-
- Veteran Member
- Posts: 101
- Joined: 2019-05-26 18:38
Re: Reset, or clear field after save changes
I have a balance field that I'm updating with 2 other fields, add_used, and add_purch. The math is working to change the balance each time that I save changes even if I put a 0.00 in either of the add fields, but I'd like to zero out the add_used and/or add_purch fields after clicking the Save Changes button. The balance field is a read only calculated field. I could do this I suppose with another table, but it would be nice to make this work if it is doable.
Thanks,
David
Thanks,
David
Re: Reset, or clear field after save changes
Hi,
you could try to to use the TABLENAME-dv.js
and add:
you could try to to use the TABLENAME-dv.js
and add:
Code: Select all
$j(function {
if($j('[name="SelectedID"]').length) {
$j('#YOURFIELD').val('0');
}
})
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
-
- Veteran Member
- Posts: 101
- Joined: 2019-05-26 18:38
Re: Reset, or clear field after save changes
Great! I'll give it a try when I return home from work this evening. Thank you, much appreciated as usual.
David
David
-
- Veteran Member
- Posts: 101
- Joined: 2019-05-26 18:38
Re: Reset, or clear field after save changes
Unfortunately that didn't change the add_used field. I may have something wrong here though. mnt_inv_now is the Table and add_used is the field.
$j(function {
if($j('[mnt_inv_now="SelectedID"]').length) {
$j('#add_used').val('0');
}
})
Thanks,
David
$j(function {
if($j('[mnt_inv_now="SelectedID"]').length) {
$j('#add_used').val('0');
}
})
Thanks,
David
Re: Reset, or clear field after save changes
Hi,
you changed the selector. So I guess that is the problem.
Try
$j(function {
if($j('[name="SelectedID"]').length) {
$j('#add_used').val('0');
}
})
you changed the selector. So I guess that is the problem.
Try
$j(function {
if($j('[name="SelectedID"]').length) {
$j('#add_used').val('0');
}
})
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
-
- Veteran Member
- Posts: 101
- Joined: 2019-05-26 18:38
Re: Reset, or clear field after save changes
My apologies, I should have mentioned that I did try leaving the selector as name before last post, but no luck there either.
Thanks,
David
Thanks,
David
Re: Reset, or clear field after save changes
Hi,
that is strange. On my testsystem it works fine. What type of field is the add_used? Where did you put the code? Maybe you can post that file.
that is strange. On my testsystem it works fine. What type of field is the add_used? Where did you put the code? Maybe you can post that file.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
-
- Veteran Member
- Posts: 101
- Joined: 2019-05-26 18:38
Re: Reset, or clear field after save changes
The add_used and add_purch fields are of Decimal Type with a default value of 0.00
Thanks,
David
Thanks,
David
- Attachments
-
- mnt_inv_now-dv-js.zip
- (436 Bytes) Downloaded 93 times
Re: Reset, or clear field after save changes
Hi,
can you please try once with only the code that I provided (comment all the rest).
Both fields are input fields, correct?
can you please try once with only the code that I provided (comment all the rest).
Both fields are input fields, correct?
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
-
- Veteran Member
- Posts: 101
- Joined: 2019-05-26 18:38
Re: Reset, or clear field after save changes
Okay, commented all other code above, and yes, both are input fields. For some reason, still didn't work on my end. Also cleared browser cache, then deleted existing test records, and created new records just in case the cache was a problem.
-
- Veteran Member
- Posts: 101
- Joined: 2019-05-26 18:38
Re: Reset, or clear field after save changes
pböttcher's code was of course spot on. The problem was with a file on my end. Thank you for the expertise!
David
David