Remove empty space when visible property is set to false using JavaScript

I’m having a DropdownList and when its Selected Value is changed (for ex: 0 ) I need to set the visible property of a Panel to True and the visible property of another Panel to False.

and when another Value is selected I need to do Vice Versa Using JAVASCRIPT.

I’m currently achieving this but the space remains as it is. How can i remove the spaces also.

can anyone help me??

I’m attaching the code also.

function visible(val) {

    var ddl = document.getElementById("ddl_IDProof");
    var selectedFilterType = drpFilterType.options[ddl.selectedIndex].value;

    if (selectedFilterType == "0") {

        document.getElementById("pnl1").style.visibility = "visible";
        document.getElementById("pnl2").style.visibility = "hidden";
    }

    else {
        document.getElementById("pnl1").style.visibility = "hidden";
        document.getElementById("pnl2").style.visibility = "visible";
    }  
}

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Use display instead of visibility.
This will hide the entire element:

    // Show pnl1 (maybe you have to use inline or inline-block insdead of block)
    document.getElementById("pnl1").style.display = "block";
    // Hide pnl2
    document.getElementById("pnl2").style.display = "none";


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x