Welcome to the nuBuilder forums!

Please register and login to view forums and other content only available to registered users.

Change a database value before display

Post Reply
agnar
Posts: 37
Joined: Sun Apr 21, 2013 10:58 pm

Change a database value before display

Unread post by agnar »

Basically, I need to change the value of a database field before it is displayed in an edit form.

For, examle, I might set a date to the current date (say, as a last modification date)

I can set a default value for a new record easilly, but can't figure out how to do it on an existing record.

Agnar
massiws
Posts: 503
Joined: Thu May 24, 2012 2:08 am
Location: Milan, Italy
Contact:

Re: Change a database value before display

Unread post by massiws »

Agnar, you could use nuLoadThis() function in Custom Code > Javascript.
For example:

Code: Select all

if ( $("#your_field").val() === '' ) {
  $("#your_field").val('default value');
}
If the field isn't on the form you can:
  • use AJAX call to get the value from DB;
  • load the value field in a hidden field on the form.
If you change the value via Javascript, remember to update the field in DB using uDB() function.

Hope this helps,
Max
Post Reply