Welcome to the nuBuilder forums!

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

Updating field in javascript

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

Updating field in javascript

Unread post by massiws »

I have this code in 'on change' field of a dropdown object:

Code: Select all

 var chiuso = '14ff917726f5cc';	// status ID
 
 var rstID = document.getElementById('rst_status_id').value;
 if(rstID == chiuso) {
	// Formatta la data odierna

     var today = new Date();
     var d = today.getDate();
     var m = today.getMonth() + 1;
     var y = today.getFullYear();
	   
      today = (d<=9?'0'+d:d)+'-'+(m<=9?'0'+m:m)+'-'+y;
  	document.getElementById('rst_ritired').value = today;
  	uDB('rst_ritired');
}
When I select one particular value in the dropdown field, the code should set the rst_ritired value with today's date.
I display correctly the change on the form, but when I save the record the rst_ritired field in db is '0000-00-00'. Why??

I solved it by checking the two fields in PHP in the AfterSave form field, but I think this is not the right way.
Any suggestion?

Thanks.
admin
Site Admin
Posts: 2781
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5
Been thanked: 1 time

Re: Updating field in javascript

Unread post by admin »

massiws,

Are you sure you have a field called rst_ritired in the table?

It doesn't sound like a javscript problem.

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

Re: Updating field in javascript

Unread post by massiws »

Steven,

sorry, I made a spelling error: the field name is rep_ritired.

I read again the wiki about the uDB() function and rewritten my code:

Code: Select all

uDB(document.getElementById('rep_ritired'))
Now it works fine!

Thanks.
admin
Site Admin
Posts: 2781
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5
Been thanked: 1 time

Re: Updating field in javascript

Unread post by admin »

good news!
Locked