473,287 Members | 2,682 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,287 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 8897
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
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.