troubleshooting Question

How to make all the other document element set to style.display = "" if I don't exactly know they're id's?

Avatar of rss2
rss2 asked on
JavaScriptASP.NETVisual Basic.NET
9 Comments1 Solution249 ViewsLast Modified:
Hi guys and girls,

I have a page which populates <div>'s and when the user click's a particular row the related <div> will appear. I'm using javascript so it's all kind of ajax-y I guess.

My question is with the javascript. I'm passing in the rowID to toggle the show/hide of the <div>. I have given each <div> an ID which has the rowID in it so i can find it with the following line:
var tm = "tab1_" + id;
document.getElementById(tm).style.display = "none";

Set that particular <div>'s appearance (either "none" or "") works fine.

My question is, how do I make all the other <div>'s disappear? If they are not the selected row, how do I include in the javascript to set all the other <div>'s to style.display = ""?

here is my page with the javascript and stuff..
<%@ Page Language="VB" MasterPageFile="~/MasterPages/MasterPage.master" AutoEventWireup="false" CodeFile="Manage.aspx.vb" Inherits="Deployments_Manage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

       <script type="text/javascript" language="javascript">
        function fn_ChangeDisplay(rowId)
        var oRowDetails = document.getElementById('DetailRow');
       = "block";
       = "visible";
            //return true;
        function getItem(id)
        var itm = false;
            itm = document.getElementById(id);
        else if(document.all)
            itm = document.all[id];
        else if(document.layers)
            itm = document.layers[id];

        return itm;

    function toggleItem(id)
        itm = getItem(id);

            return false;
        var im = id + "_toggle";
        var tm = "tab1_" + id;

        if( == 'none') {
   = '';
            document.images[im].src = "../images/minus.gif";
            //document.getElementById("TargetGroup").style.display = "";
            //document.getElementById("Release").style.display = "none";
            //document.getElementById("tab1").style.display = "";
            document.getElementById(tm).style.display = "";
            //document.getElementById("tab1_1").style.display = "";
            //document.getElementById("tab1_4").style.display = "";
            //document.getElementById("tab1_7").style.display = "";
        else {
   = 'none';
            document.images[im].src = "../images/plus.gif";
            //document.getElementById("TargetGroup").style.display = "none";
            //document.getElementById("Release").style.display = "";
            //document.getElementById("tab1").style.display = "none";
            //document.getElementsByName("tab1").style.display = "";
            document.getElementById(tm).style.display = "none";
            //document.getElementById("tab1_1").style.display = "none";
            //document.getElementById("tab1_4").style.display = "none";
            //document.getElementById("tab1_7").style.display = "none";
        return false;

<h2>Manage Deployments</h2>
<div id="firstdiv" runat="server">
<div id="hrborder">
<hr style="color: #e0e0e0; width: 100%"/>

<div class="bodytext" id="main">
    <div class="content">

<div id="tabdiv" runat="Server">



Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 9 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros