The CreatorCon Call for Content is officially open! Get started here.

How to Toggle Form Tab to Active but Not Hide

Spaceballs
Kilo Sage

Hi 

How do you toggle the tab to active but not hide based on the dropdown selection?

 

if the Status =  planning

Spaceballs_0-1674576067585.png

 

then toggle the tab to Planning tab but do not hide the other tabs. 

Spaceballs_1-1674576091302.png

 

Client Script code

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    /*var sections = g_form.getSectionNames();
		alert(sections);*/
    if (g_form.getValue('status') == 'planning') {
        g_form.setSectionDisplay('planning', true);
    } else {
        g_form.setSectionDisplay('planning', false);
    }
}

 

 

1 ACCEPTED SOLUTION

Spaceballs
Kilo Sage

Thanks for the help, I found my own solution.

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    if (g_form.getValue("status") == "planning") {
        g_tabs2Sections.setActive(2);

    } else if (g_form.getValue("status") == "fieldwork" || g_form.getValue("status") == "manager_review") {
        g_tabs2Sections.setActive(3);

    } else if (g_form.getValue("status") == "finalizing" || g_form.getValue("status") == "director_review") {
        g_tabs2Sections.setActive(4);

    } else if (g_form.getValue("status") == "vp_review") {
        g_tabs2Sections.setActive(5);
    } 
}

 

View solution in original post

4 REPLIES 4

Basheer
Mega Sage

Hi @Spaceballs ,

We did something similar using below script

var tabName = 'new, test, done';
var myTabs = $('tabs2_section').select('span[class="tab_header"]');
var answer = 0;
for (i = 0; i < myTabs.length; i++) {
   var inner = myTabs[i].innerHTML.replace(/&amp;nbsp;/g, ' ');
   if(inner.indexOf(tabName) > -1) {
      answer = i;
      break;
    }
}
//Display the selected section
g_tabs2Sections.setActive(answer);
Please hit like button if my suggestion has helped you in any way.
Please mark correct if my response has solved your query.

Cheers,
Mohammed Basheer Ahmed.

Hi @Basheer ,

 

Thanks for the code but I'm getting error: onChange script error: TypeError: $ is not a function function () { [native code] }

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    /*var sections = g_form.getSectionNames();
    alert(sections);*/
    var tabName = 'milestones, assigned_to, planning,';
    var myTabs = $('planning').select('span[class="tab_header"]');
    var answer = 0;
    for (i = 0; i < myTabs.length; i++) {
        var inner = myTabs[i].innerHTML.replace(/\x26nbsp;/g, ' ');
        if (inner.indexOf(tabName) > -1) {
            answer = i;
            break;
        }
    }
    //Display the selected section
    g_tabs2Sections.setActive(2);
}

Spaceballs
Kilo Sage

Thanks for the help, I found my own solution.

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    if (g_form.getValue("status") == "planning") {
        g_tabs2Sections.setActive(2);

    } else if (g_form.getValue("status") == "fieldwork" || g_form.getValue("status") == "manager_review") {
        g_tabs2Sections.setActive(3);

    } else if (g_form.getValue("status") == "finalizing" || g_form.getValue("status") == "director_review") {
        g_tabs2Sections.setActive(4);

    } else if (g_form.getValue("status") == "vp_review") {
        g_tabs2Sections.setActive(5);
    } 
}