I thought this would be easier than it seems to be!
im trying to take a date of birth and initials and create a unique code to also identify a client (for use by people). this is automaticly generated when adding the clients details.
the following code works, in that it puts the code into the easycode field (ive tried text input and textarea and calculated fields), but DOESNT save to the database UNLESS you go into the easycode field and edit it
after entering the persons date of birth, i used the customcode on event =onchange
var dobval = document.getElementById("cli_dob").value;
var doini = document.getElementById("cli_ini").value;
var dobstr = dobval.toString();
var dobday =dobstr.charAt(0)+dobstr.charAt(1);
var dobyr = dobstr.charAt(8)+dobstr.charAt(9);
var make =document.getElementById('cli_easycode').value;
var all=doini+dobday+dobyr;
cli_easycode.value = all;
cli_easycode.value = cli_easycode.value;
how do you get the stored value (which shows up in the field) to update the database? (ive tried a few different methods)
many thanks
Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
code to calculate strings into a field
-
- nuBuilder Team
- Posts: 4299
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 445 times
- Contact:
Re: code to calculate strings into a field
You need to trigger the change event. I think it's easier with jQuery.
So, instead of
Write:
nuBuilder only saves records that have a class of "nuEdited"
So, instead of
Code: Select all
cli_easycode.value = all;
Code: Select all
$('#cli_easycode').val(all).change();
nuBuilder only saves records that have a class of "nuEdited"
Last edited by kev1n on Fri Aug 14, 2020 3:12 pm, edited 1 time in total.
-
- nuBuilder Team
- Posts: 4299
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 445 times
- Contact:
Re: code to calculate strings into a field
Or with pure Javascript, this should work too:
Code: Select all
cli_easycode.value = all;
cli_easycode.classList.add("nuEdited");
-
- Posts: 7
- Joined: Sat Aug 08, 2020 12:13 pm
Re: code to calculate strings into a field
works a treat kev1n, thanks
BTW is there a video showing how the staff roster was created or is there a sample database?
I cant beleive a system as powerful and adaptable as this was sooo hard for me to find (ive been looking at software for months).
anything I can do to spread the word, let me know!
BTW is there a video showing how the staff roster was created or is there a sample database?
I cant beleive a system as powerful and adaptable as this was sooo hard for me to find (ive been looking at software for months).
anything I can do to spread the word, let me know!
-
- nuBuilder Team
- Posts: 4299
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 445 times
- Contact:
Re: code to calculate strings into a field
Some sample databases can be found here:
https://sourceforge.net/projects/nubuil ... databases/
https://sourceforge.net/projects/nubuil ... databases/
Yes please. Share it on social media, other forums, with friends etc!pbweb1969 wrote: anything I can do to spread the word, let me know!
-
- nuBuilder Team
- Posts: 4299
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 445 times
- Contact:
Re: code to calculate strings into a field
PS: You'll need to import the sample into a new nuBuilder database.