function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Praveen Venkata BPraveen Venkata B 

Disable/Enable Jquery UI tabs based on multiple conditions

I'm trying to enable to disable/Enable tabs based on multiple conditions on Visualforce page. Below is my JS and Tabs UI code:

Out of two if conditions, only the last if condition is disabling tabs even when both of the if conditions are true. When both the conditions are true, i'm getting alter messages for both but only the last if condition is actually disabling tabs but not the first if condition.

Please help me !!
function disableEnableTabs()
    {
        var variable1=value can be either true/false;
        var variable2=count of some records;
        var variable3=value can be either Active or Inactive;
        
        if(variable3!='Active' || variable1=='false')
        {
            $("#tabs").tabs("option", {
            "disabled": [2]
            });
            alert("Into Active or False");
        }
        
        if(variable2==0)
        {
            $("#tabs").tabs("option", {
            "disabled": [3,4]
            });
            alert("Into Count");
        }
        
        else
        {
            $("#tabs").tabs('enable');
        }
<div id="tabs" clas="ui-tabs ui-widget ui-widget-content ui-corner-all" style="border:none;">
        <div >
            <ul class="nav nav-tabs">
                <li class="active">
                    <a href="#tab1" style="text-decoration:none; font-weight: 700; color:black">Tab A</a>
                </li>
                <li>
                    <a href="#tab2" style="text-decoration:none; font-weight: 700;color:black">Tab B</a>
                </li>
                <li>
                    <a href="#tab3" style="text-decoration:none; font-weight: 700;color:black">Tab C</a>
                </li>
                <li>
                    <a href="#tab4" style="text-decoration:none; font-weight: 700;color:black">Tab D</a>
                </li>
                <li>
                    <a href="#tab5" style="text-decoration:none; font-weight: 700;color:black">Tab F</a>
                </li>
            </ul>   
        </div>


 
James LoghryJames Loghry
Add a debugger; statement before your if check.  Open Chrome developer console.  When the code is supposed to disable the tabs, you should hit the debugger statement and see a break point.  At that time, you can investigate what the value of variable3 and variable1 are by typing variable1; into the developer console.  Whatever value that variable1 / variable3 are set to, is what you need in your if statement.  

It looks like you may need to check if variable1 == false instead of variable1 == 'false' though, as I'm guessing variable1 is a boolean value rather than a string type.