Results 1 to 2 of 2

Thread: [RESOLVED] Why won't both button script run?

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2021
    Posts
    8

    Resolved [RESOLVED] Why won't both button script run?

    So I am modifying the ASPX page since we don't have the CODE BEHIND. These are just minor visual changes.

    When BUTTON C is pressed, the displayed labels numerator is wrong. So a fix is just to remove the denominator.

    Name:  CaptureA.jpg
Views: 109
Size:  6.4 KB
    FIXED
    Name:  Capture-AA.jpg
Views: 104
Size:  6.1 KB

    When BUTTON E is pressed, it shows 2 DIVs when there should only be one. So the fix is to hide the wrong one.

    Name:  CaptureB.jpg
Views: 79
Size:  11.4 KB
    FIXED
    Name:  Capture-BB.jpg
Views: 106
Size:  7.3 KB


    The issue is that it looks I can't have both fix on the script. Below, only one shows the FIX and it's the first one the script encounters (BUTTON C). If I place BUTTON E script before BUTTON C, BUTTON E fix would be visible.

    Any ideas? TIA

    HTML Code:
    <script>
    
    	//THIS IS FOR BUTTON C
        var z = document.getElementById("m_eiamExpandCollapseActiveDiv");
        if (z.visibility !== "hidden") {
            document.getElementById("m_ei1amActiveSumLBL").innerHTML = document.getElementById("m_ei1amActiveSumLBL").innerHTML.replace(/\/\d*/, "");
            document.getElementById("m_ei1amAbsentSumLBL").innerHTML = document.getElementById("m_ei1amAbsentSumLBL").innerHTML.replace(/\/\d*/, "");
            document.getElementById("m_ei1amLateSumLBL").innerHTML = document.getElementById("m_ei1amLateSumLBL").innerHTML.replace(/\/\d*/, "");
            document.getElementById("m_ei1amEarlySumLBL").innerHTML = document.getElementById("m_ei1amEarlySumLBL").innerHTML.replace(/\/\d*/, "");
        }
    
    
    	// THIS IS FOR BUTTON E
        var x = document.getElementById("m_eipmExpandCollapseActiveDiv");
        var y = document.getElementById("m_autamExpandCollapseActiveDiv");
        if ((x.visibility !== "hidden") && (y.visibility !== "hidden")) {
            document.getElementById("m_eipmExpandCollapseActiveDiv").style.display = 'none';
        } 
    
    </script>

  2. #2

    Thread Starter
    New Member
    Join Date
    Jan 2021
    Posts
    8

    Re: Why won't both button script run?

    OK I think I figured it out because this script now works.

    It looks like I have to check first if the element is in the page (not null). I found the error when I used the browser to trace the script. New with this direct to aspx scripting.

    Code:
    <script>
        
        //THIS IS FOR BUTTON C
        if (document.getElementById("m_eiamExpandCollapseActiveDiv")) {
            var z = document.getElementById("m_eiamExpandCollapseActiveDiv");
            if (z.visibility !== "hidden") {
                document.getElementById("m_ei1amActiveSumLBL").innerHTML = document.getElementById("m_ei1amActiveSumLBL").innerHTML.replace(/\/\d*/, "");
                document.getElementById("m_ei1amAbsentSumLBL").innerHTML = document.getElementById("m_ei1amAbsentSumLBL").innerHTML.replace(/\/\d*/, "");
                document.getElementById("m_ei1amLateSumLBL").innerHTML = document.getElementById("m_ei1amLateSumLBL").innerHTML.replace(/\/\d*/, "");
                document.getElementById("m_ei1amEarlySumLBL").innerHTML = document.getElementById("m_ei1amEarlySumLBL").innerHTML.replace(/\/\d*/, "");
            }
        }
    
    
        // THIS IS FOR BUTTON E
        if ((document.getElementById("m_eipmExpandCollapseActiveDiv")) && (document.getElementById("m_autamExpandCollapseActiveDiv"))) {
            var x = document.getElementById("m_eipmExpandCollapseActiveDiv");
            var y = document.getElementById("m_autamExpandCollapseActiveDiv");
            if ((x.visibility !== "hidden") && (y.visibility !== "hidden")) {
                document.getElementById("m_eipmExpandCollapseActiveDiv").style.display = "none";
            }
        }
    
    </script>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width