Page 1 of 1
Set default values in form
Posted: Thu Aug 20, 2020 11:21 pm
by treed
Hello All, I've followed the video tutorial on the subject and when a new record is added the correct default value shows in the select box. However when the record is saved the new value is null. Here's my code.
if(nuIsNewRecord()){
$('#OutContidion').val(1).change;
}
The value 1 has the word New attached to it and New is what is shown in the selection box. Anyone have an idea what the issue might be?
Re: Set default values in form
Posted: Thu Aug 20, 2020 11:26 pm
by treed
Additional info, even selecting the "New" value from the select box does saves a null value. If the record is edited the chosen value does save.
Re: Set default values in form
Posted: Fri Aug 21, 2020 3:00 am
by kev1n
The syntax is wrong
Code: Select all
$('#OutContidion').val(1).change()
Re: Set default values in form
Posted: Mon Aug 24, 2020 6:00 pm
by treed
Thanks! sometimes another set of eyes helps. Added the () and all works. And now when I go to leave the page I've got to cancel the changes because the code starts the edit process. Perhaps that code can go under a different event. Looks like it would need to be PHP to do that though.
Re: Set default values in form
Posted: Mon Aug 24, 2020 6:06 pm
by kev1n
treed wrote:And now when I go to leave the page I've got to cancel the changes because the code starts the edit process. Perhaps that code can go under a different event. Looks like it would need to be PHP to do that though.
Add nuHasNotBeenEdited(); after changing the field.
Wiki wrote:This will set the status of an Edit Form to not Edited and do 2 things
The Save Action Button will return to its normal color.
The web browser will not alert the user when leaving the current record.
Code: Select all
if (nuFormType() == 'edit') {
$('#OutContidion').val(1).change();
nuHasNotBeenEdited();
}
Re: Set default values in form
Posted: Tue Aug 25, 2020 12:38 am
by treed
Again, Thank you very much. Is there a reference somewhere for all these nice JavaScript functions???
Re: Set default values in form
Posted: Tue Aug 25, 2020 12:58 am
by admin