473,385 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Hide TR based on innerHTML

Hi there,

I'm new to the board and hope I can get answer from any of you.

My problem: I want to hide an tr in a table based on the innerhtml.
I got this

[HTML]<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>

<script language="javascript">

window.onload = function hide(){
<!-- Alert to see if it gets the right tr for test only. -->
alert(document.getElementById("hidethis").innerHTM L);

var hideornot = document.getElementById("hidethis").innerHTML
var div = document.getElementById("hidethis")

if(hideornot == "<td width='100%' bgcolor='#000666'>"){
div.style.display = ' '
}
else
{
div.style.display = 'none'
}
}
</script>


</head>

<body >
<table width="100" border="0" align="center" cellpadding="0" cellspacing="0">
<tr id="hidethis">
<td width="100%" bgcolor="#000666">teds</td>
</tr>
</table>
</body>
[/HTML]

It's not showing or hidding if I change for example the bgcolor to #006666.
Hope you can help me or give me a hint in the right direction.

Thank you for reading
Greetings

Jeroen
Sep 12 '07 #1
3 3204
gits
5,390 Expert Mod 4TB
hi ...

welcome to TSDN ...

your innerHTML is:

[HTML]<td width="100%" bgcolor="#000666">teds</td>[/HTML]
so your condition is not working. you may use a regEx to match the first part or only parts of the innerHTML you want to match ... so first try:

Expand|Select|Wrap|Line Numbers
  1. if (/^<td width="100%" bgcolor="#000666">/.test(hideornot)) { }
instead of your condition:

Expand|Select|Wrap|Line Numbers
  1. if (hideornot == "<td width='100%' bgcolor='#000666'>") { }
kind regards

ps: as we can see ... this is really ugly ... so tell me: what is the exact condition that leads to display or hide of a row?!
Sep 12 '07 #2
Thank you for the reply,

Solved it myself seemed that I could select the whole innerhtml and not just a part of it.

Thanks again.

Jeroen
Sep 14 '07 #3
gits
5,390 Expert Mod 4TB
hi ...

glad to hear that you got it working ... but one thing to mention, again:

in case you have a certain condition ... and i think there is one ... may be a certain backgroundcolor or something like that ... then there would be much better ways to do that display/hide thing ...

but of course ... in case you are satisfied with the current solution ... it's ok :)

post back to the forum anytime you have more questions ...

kind regards
Sep 14 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Christoph Bergmann | last post by:
Hi... We want to write an open source web based TEXT editor and would be happy about any help ;-) Please notice: We do NOT want to write a web based WEB editor, where you can edit a web...
2
by: John Doe | last post by:
I have a webpage which shows and hides divs as a method of navigation. It works great in the ever evil IE. It works not so great (read not at all) in any standards compliant browser. I haven't...
5
by: Mel | last post by:
i need to have 2 side by side iframes, a link on top of the one will show/hide the other can someone help me pleeeeezzzzz ?
4
by: itunes66 | last post by:
how can i do this i already have a function to show/hide elements with one link but how can i show/hide multiple elements here is the script function obj_ref(object) { if...
2
by: Eero Tuomenoksa | last post by:
Hi Does someone knows how i can show/hide multible divs at one click? -- Käytössä Operan vallankumouksellinen sähköpostiohjelma: http://www.opera.com/mail/
1
by: vj | last post by:
How i can populate all fileds dynamically in jsp page based on contents found in xml file? I have written jsp servlets and java class file. i transferred automatic data from jsp to servlet then to...
0
by: vijendra | last post by:
How i can populate all fileds dynamically in jsp page based on contents found in xml file?I have written jsp servlets and java class file. i transferred automatic data from jsp to servlet then to...
6
by: michael941 | last post by:
Hi, I have 2 tables in an html page. I have div them separately and id them as id1 and id2. I have a link there. What I need is click the link to hide one table and show the other and verse when...
5
by: question.boy | last post by:
I am trying to control the visibility of a set of div based on selected values but can't seem to get it right. Below is what I have so far but it does not work at all. The basic concept was to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.