[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 320
  • Last Modified:

Hide and display div

I found an example online to hide and display 2 divs.

I put "alert" debug..i click on one button...i see the correct values..i see the div showing...then it calls the "hide" function and that div disappears. Not sure how to do this;

Even tried this: http://blog.movalog.com/a/javascript-toggle-visibility/

even wrapped the buttons and the divs in updatepanel but still shows but disappears.
function Show(divId) {
            alert("show");
            alert(divId);
            document.getElementById(divId).style.display = "block";
            
        }
        function Hide(divId) {
            alert("hide");
            alert(divId);
            document.getElementById(divId).style.display = "none";
           
        }
---

<asp:Button ID="lbSearchSpecialty"  OnClientClick ="Show('divSpecialty'); Hide('divProvider')"  CausesValidation="false"  runat="server" Text="Search by Specialty" ></asp:Button>

<asp:Button runat="server"   OnClientClick="Show('divProvider'); Hide('divSpecialty')"  Text="Search by Provider" ID="lbSearchProvider"   CausesValidation="false"  CommandName="Select" />

-----

 <div style="display:none" id="divProvider">
       <uc1:providerSearch runat="server"  ID="ucProvider" />
    </div>

    <div style="display:none" id="divSpecialty">
       <uc1:providerSpecialty runat="server" ID="ucSpecialty" />
    </div>

Open in new window

0
Camillia
Asked:
Camillia
1 Solution
 
owaisyahyaCommented:
Modify this javascript code as

function ShowHidediv(divId)
{
alert("show");
alert(divId);
if(document.getElementById(divId).style.display=="none")
{
document.getElementById(divId).style.display = "block";
}
else
{
document.getElementById(divId).style.display = "none";
}            
}

<asp:Button ID="lbSearchSpecialty"  OnClientClick ="ShowHidediv('divSpecialty');"  CausesValidation="false"  runat="server" Text="Search by Specialty" ></asp:Button>

<asp:Button runat="server"   OnClientClick="ShowHidediv('divSpecialty')"  Text="Search by Provider" ID="lbSearchProvider"   CausesValidation="false"  CommandName="Select" />

-----

 <div style="display:none" id="divProvider">
       <uc1:providerSearch runat="server"  ID="ucProvider" />
    </div>

    <div style="display:none" id="divSpecialty">
       <uc1:providerSpecialty runat="server" ID="ucSpecialty" />
    </div>

Open in new window

0
 
CamilliaAuthor Commented:
I call it like this:
OnClientClick ="ShowHidediv('divSpecialty');ShowHidediv('divProvider');"

the divSpcialty shows up, then disappears. So when one is showing, i dont want to display the other one. But the div that was being displayed disapears.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now