473,401 Members | 2,127 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,401 software developers and data experts.

How to show/hide borders in a table

As it isnow i have to use a syntax for my tables as:
<table class = "some" border>
and/or
<table class = "some" noborder>

Now, what i'd like to do is to make that border-thingy
appear/desappear using javascript. Is it solvable that
way? I tried to rely on CSS but i didn't find any good
info on this matter...

Of course if anybody knows how to do it with CSS
that would be even more great.

--

Vänligen
Konrad
---------------------------------------------------

Sleep - thing used by ineffective people
as a substitute for coffee

Ambition - a poor excuse for not having
enough sense to be lazy

---------------------------------------------------

Aug 28 '05 #1
4 8903
Konrad Viltersten wrote:
As it isnow i have to use a syntax for my tables as:
<table class = "some" border>
and/or
<table class = "some" noborder>

Now, what i'd like to do is to make that border-thingy
appear/desappear using javascript. Is it solvable that
way? I tried to rely on CSS but i didn't find any good
info on this matter...

Of course if anybody knows how to do it with CSS
that would be even more great.


You can use JavaScript to change the CSS class of the table, or to
change its border attribute value, or its style object. To be silly
about it you could also change a style rule that applies to the table,
but that may be going too far.

Which way is best depends on a number of factors, such as what event you
would like to use to make it change, how many there are to change
simultaneously and whether it's OK if nothing happens if script or CSS
support is not available.
--
Rob
Aug 28 '05 #2
>> As it isnow i have to use a syntax for my tables as:
<table class = "some" border>
and/or
<table class = "some" noborder>

Of course if anybody knows how to do it with CSS
that would be even more great.


You can use JavaScript to change the CSS class of the table, or to
change its border attribute value, or its style object. To be silly
about it you could also change a style rule that applies to the
table, but that may be going too far.

OK, that's good. The thing is that even if i can controll the
event that is suppose to make the change i'm still rather
ignorant about what the name of the property is. To be sure
we're talking about the same thing - i'm not refering to a
border *around* the object (i.e. table) but the borders
*inside* a table. How do we get to them?

--

Vänligen
Konrad
---------------------------------------------------

Sleep - thing used by ineffective people
as a substitute for coffee

Ambition - a poor excuse for not having
enough sense to be lazy

---------------------------------------------------

Aug 28 '05 #3
Konrad Viltersten wrote:
As it isnow i have to use a syntax for my tables as:
<table class = "some" border>
and/or
<table class = "some" noborder>

Of course if anybody knows how to do it with CSS
that would be even more great.


You can use JavaScript to change the CSS class of the table, or to
change its border attribute value, or its style object. To be silly
about it you could also change a style rule that applies to the
table, but that may be going too far.


OK, that's good. The thing is that even if i can controll the
event that is suppose to make the change i'm still rather
ignorant about what the name of the property is. To be sure
we're talking about the same thing - i'm not refering to a
border *around* the object (i.e. table) but the borders
*inside* a table. How do we get to them?


I think now you are into CSS more than JavaScript, but let's keep going.
The borders 'inside' the table belong the rows and cells, so use
something that sets them to what you want then modify them.

Below is a simple example . Production will require far more thought and
rigour - help with that can be provided once your requirements are known
in more detail:
<head>

<style type="text/css">
table { border: 1px dotted red;}
.cellA {border: 1px solid blue;}
.cellB {border: 1px solid red;}
</style>

<script type="text/javascript">
function toggleClass( el ){
if ( el.className ){
el.className = ('cellA' == el.className)? 'cellB':'cellA';
}
}
</script>

</head>
<body>

<table>
<tr>
<th>Here is a head cell</td>
<th>And another head cell</td>
</tr>
<tr>
<td class="cellA" onclick="
toggleClass(this)
">Here is a cell</td>
<td class="cellA" onclick="
toggleClass(this)
">And another cell</td>
</tr>
</table>

</body>

--
Rob
Aug 28 '05 #4
Konrad Viltersten wrote :

To be sure
we're talking about the same thing - i'm not refering to a
border *around* the object (i.e. table) but the borders
*inside* a table. How do we get to them?


Then just modify the rules attribute and set it to none.

<table id="Scores" rules="all">
....
</table>

In your script,

document.getElementById("Scores").rules = "none";

Gérard
--
remove blah to email me
Aug 28 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Michael Skind | last post by:
Hello, I use a simple Table : <TABLE> <TR 1> <TD></TD> </TR> <TR 2> <TD></TD> </TR>
7
by: Mad Scientist Jr | last post by:
Through messing around I got IE6 (win xp) to show/hide a table row. I gave my <TR> an ID of "trRow" and trRow.style.display='none'; hides it trRow.style.display='block'; displays it (will any...
7
by: NeverLift | last post by:
I posted a very long message regarding my experiences with JavaScript, one reply was posted asking I post an example of the problem -- and both are gone! Is there a moderator that removes such...
10
by: oLE | last post by:
I would like to add some javascript to show/hide a certain row of a table. The first row of the table contain the hyperlink that calls the javascript the second row is the one i want to show/hide...
1
by: le_sloth | last post by:
Hi I'm generating a series of reports from an application that will be published on a client's intranet. The idea is that each of these reports is arranged into major product groups,...
2
by: MOHSEN KASHANI | last post by:
Hi, I am trying to hide some form elements in a form by default and show/hide depending on which radio button is clicked. This is what I have but it is not working: <head> <style> ..noshow {...
1
by: pamate | last post by:
hi, I want to show hide layers. I am able to show and hide layers but i am facing problem that, cant view the cursor in Mozilla,but i can type in input text box, its overlapping the layers. ...
18
by: Liquidtouch | last post by:
I have been searching on this for awhile and cant find anything and playing around with it got me no where. I will start with what I am after and then explain what I have. I have a table with 3...
1
oranoos3000
by: oranoos3000 | last post by:
hi would you please help me i have a online shopping center that i show pictures of the my product in home page. in the InterExplorer pictures is shown correctly but in Firefox browser is shown...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.