/    Sign up×
Community /Pin to ProfileBookmark

Hiding a TR table element

Hi all,

I have this TR defined in my HTML

[CODE]<tr id=”trSupervisorHeading” runat=”server” >[/CODE]

So what I want to do, in the code behind page (vb.net) I have the page_load event filling several data grids. I have a if statement that tests if there are any items in a specific datagrid, if not I want it to hide the TR mentioned above.

What I have at the moment is:

[CODE]Response.Write(“<script language = ‘Javascript’>document.getElementById(‘trSupervisorHeading’).style.visibility =’hidden’;</script>”)[/CODE]

but I get an error “Object required.”, when I open the page, I have also added:

[CODE]Response.Write(“<script language = ‘Javascript’>alert(‘dgapprove.items.count =0!’);</script>”)[/CODE]

and this works fine.

I was hoping someone would be able to help me, or point me in the right direction.

Thanks.

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@CrazyMerlinMar 14.2007 — ok, dump the runat and try again
Copy linkTweet thisAlerts:
@KorMar 14.2007 — I guess you need either to place the response.Write after the element or, better, to use the onload event to start a function, otherwise you will always to refer an element which is not loaded yet

Try this
<i>
</i>Response.Write("&lt;script type='text/javascript'&gt;onload=function(){document.getElementById('trSupervisorHeading').style.visibility ='hidden'}&lt;/script&gt;")
Copy linkTweet thisAlerts:
@cardonaauthorMar 14.2007 — It's a beautiful thing!

Thanks Kor, worked like a charm.

Should I loose the runat="server" ? It is still there, but is working, and I only put it there while I was trying stuff myself.
Copy linkTweet thisAlerts:
@cardonaauthorMar 15.2007 — There's always something else....

now that I have the 'TR' hidden as well as another one, there are big gaping spaces between the next two sections (where the trSupervisor was removed.) is there a way to move the other elements up?
Copy linkTweet thisAlerts:
@KorMar 15.2007 — use [B]style.display='none'[/B] instead of [I]style.visibility='hidden'[/I]
×

Success!

Help @cardona spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.1,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...