Welcome to the nuBuilder Forums!

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

Readonly + Select Field Combine

Questions related to using nuBuilder Forte.
kev1n
nuBuilder Team
Posts: 4307
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 447 times
Contact:

Re: Readonly + Select Field Combine

Unread post by kev1n »

Give this a try:

Code: Select all

if (nuFormType() == 'edit') {
    typeChanged(1, '1W11');
    typeChanged(2, '1W21');
}

var arrWagen1 = {
    Original: ['1W14'],
    BBQ: ['1W15'],
    Chili: ['1W16']
}

var arrWagen2 = {
    Original: ['1W24'],
    BBQ: ['1W25'],
    Chili: ['1W26']
}

function enableType(wagen, type, enable) {
    var arr = (wagen == 1) ? arrWagen1 : arrWagen2;
    for (f in arr[type]) {
        nuEnable(arr[type][f], enable);
    }
}

function enableTypes(wagen, o, b, c) {
    enableType(wagen, 'Original', o);
    enableType(wagen, 'BBQ', b);
    enableType(wagen, 'Chili', c);
}

function typeChanged(wagen, id) {

    var type = $("#" + id + " option:selected").text();
    switch (type) {
        case "Original":
            enableTypes(wagen, true, false, false);
            break;
        case "BBQ":
            enableTypes(wagen, false, true, false);
            break;
        case "Chili":
            enableTypes(wagen, false, false, true);
    }

}

Also change the onchange event of the Sorte selects of Wagen 1 + Wagen 2:

Wagen1, Sorte Select:

Code: Select all

typeChanged(1, '1W11');
Wagen2, Sorte Select:

Code: Select all

typeChanged(2, '1W21');
Olikun
Posts: 68
Joined: Tue Mar 09, 2021 6:45 pm

Re: Readonly + Select Field Combine

Unread post by Olikun »

thanks, it works

but how about the second form where the select field is a text field?
kev1n
nuBuilder Team
Posts: 4307
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 447 times
Contact:

Re: Readonly + Select Field Combine

Unread post by kev1n »

Replace that line again

Code: Select all

var type = $("#" + id + " option:selected").text();
with

Code: Select all

var type = $("#" + id).val();
Post Reply