Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Select object, exclude certain items for new records

Questions related to using nuBuilder Forte.
Post Reply
marc
Posts: 92
Joined: Mon May 14, 2018 3:26 pm

Select object, exclude certain items for new records

Unread post by marc »

My select field contains values (years) like 2019, 2018, 2017. For new records, the previous years should be excluded (2018, 2017) and only the current year should be in the drop down list. How can I do that?
kev1n
nuBuilder Team
Posts: 4307
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 448 times
Contact:

Re: Select object, exclude certain items for new records

Unread post by kev1n »

Replace your_select_id with your select object id, add this code to the form's js field:

Code: Select all

if(nuIsNewRecord()) {
    var currentYear = new Date().getFullYear();
    $('#your_select_id option').filter(function () {
        return parseInt(this.value) < currentYear;
    }).remove();
}
admin
Site Admin
Posts: 2815
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Select object, exclude certain items for new records

Unread post by admin »

Glen,

kev1n knows what he's talking about...

https://wiki.nubuilder.cloud/ ... b_-_Select


Steven
Post Reply