最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

c# - Remove empty space when visible property is set to false using JavaScript - Stack Overflow

matteradmin5PV0评论

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";
    }  
}

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";
    }  
}
Share Improve this question asked Aug 17, 2012 at 10:39 Krishna ThotaKrishna Thota 7,08617 gold badges58 silver badges79 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

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";
Post a comment

comment list (0)

  1. No comments so far