Client Side script to hide a section if a true / false field has a value of false

RobertPC
Tera Contributor

I created a Client Side script to hide a section called Database if the field u_database is set to false, but it is not working. Can someone tell me what I am doing wrong please.

 

function onLoad() {
    var databaseFieldValue = gForm.getValue('u_database');

    if (databaseFieldValue === 'false') {
        gForm.setSectionDisplay('Database_section', false);
    } else {
        gForm.setSectionDisplay('Database_section', true);
    }
}
1 ACCEPTED SOLUTION

Robert H
Mega Sage

Hello @RobertPC ,

 

Please try this:

 

function onLoad() {
    g_form.setSectionDisplay('Database_section', g_form.getValue('u_database') != 'false');
}

 

Regards,

Robert

View solution in original post

2 REPLIES 2

BrianProvencher
Giga Guru
You've got the wrong syntax for g_form. Try this:
 
function onLoad() {
    var databaseFieldValue = gForm.getValue('u_database');

 

    if (databaseFieldValue === 'false') {
        g_form.setSectionDisplay('Database_section'false);
    } else {
        g_form.setSectionDisplay('Database_section'true);
    }
}

Robert H
Mega Sage

Hello @RobertPC ,

 

Please try this:

 

function onLoad() {
    g_form.setSectionDisplay('Database_section', g_form.getValue('u_database') != 'false');
}

 

Regards,

Robert