Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic control variable access 1

Status
Not open for further replies.

adamroof

Programmer
Nov 5, 2003
1,107
US
Hello, i have a span im trying to display using javascript from a .net page, i have the click working to expand each item individually, but im trying to have an "Expand All" button. i get err style is null or not an object.

ive tried document.getElementByID(dlProducts...), but errs with Object doesnt support this.

any input would be super!
Code:
        for (var a=2; a < 5; a++) {
          dSpan = "dlProducts__ctl"+a+"_detailSpan";
          dSpan.style.display = 'block';
          dSpan.style.visibility = 'visible';
        }

heres the one that works individually
Code:
tr2.Attributes.Add("onclick", "showContact(" + sp1.ClientID + "," + img1.ClientID + ");");

function showContact(clicked,image)
{
var elem = clicked;
    if (elem) 
    {
        if (elem.style.display != 'block') 
        {
            elem.style.display = 'block';
            elem.style.visibility = 'visible';
            image.src = "img/action/plusout.gif";
        } 
        else
        {
            elem.style.display = 'none';
            elem.style.visibility = 'hidden';
            image.src = "img/action/plusin.gif";
        }
    }
}
 
HOLY!!!!!

thats what it was...
tossed in var total and null object handling...
Code:
function showAll(total)
{       
   for (var a=0; a < total; a++) 
    {
        var dSpan = "dlProducts__ctl"+a+"_detailSpan";
        dSpan = parent.document.getElementById(dSpan);
        if (dSpan){
            dSpan.style.display = 'block';
            dSpan.style.visibility = 'visible';
        }
    }
}



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top