469,280 Members | 2,449 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,280 developers. It's quick & easy.

How to change table border from javascript?

Whats wrong with this?

top.document.frmMain.tabMain.border = "1";

thanks
Jul 20 '05 #1
9 43215
"Harry" <a@abc.com> wrote in message
news:A1*********************@news-text.cableinet.net...
Whats wrong with this?

top.document.frmMain.tabMain.border = "1";


It has no context.

Richard.
Jul 20 '05 #2
how would I do it then? - what am I missing?

thanks

"Richard Cornford" <Ri*****@litotes.demon.co.uk> wrote in message
news:bn*******************@news.demon.co.uk...
"Harry" <a@abc.com> wrote in message
news:A1*********************@news-text.cableinet.net...
Whats wrong with this?

top.document.frmMain.tabMain.border = "1";


It has no context.

Richard.

Jul 20 '05 #3
In article <n8*********************@news-text.cableinet.net>, a@abc.com
enlightened us with...
how would I do it then? - what am I missing?


You're missing the rest of the code and an explanation of what doesn't
work, what you want, and target browsers, if any.

Context = tell us what the heck you want.

-------------------------------------------------
~kaeli~
Jesus saves, Allah protects, and Cthulhu
thinks you'd make a nice sandwich.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
-------------------------------------------------
Jul 20 '05 #4
sorry, target browsers are ie 5.5 & netscape 7

I want the user to be able to click on a checkbox which will using
javascript show/hide the border of a table

thanks

harry
"kaeli" <in********************@NOSPAMatt.net> wrote in message
news:MP************************@nntp.lucent.com...
In article <n8*********************@news-text.cableinet.net>, a@abc.com
enlightened us with...
how would I do it then? - what am I missing?


You're missing the rest of the code and an explanation of what doesn't
work, what you want, and target browsers, if any.

Context = tell us what the heck you want.

-------------------------------------------------
~kaeli~
Jesus saves, Allah protects, and Cthulhu
thinks you'd make a nice sandwich.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
-------------------------------------------------

Jul 20 '05 #5
In article <2d*********************@news-text.cableinet.net>, a@abc.com
enlightened us with...
sorry, target browsers are ie 5.5 & netscape 7

I want the user to be able to click on a checkbox which will using
javascript show/hide the border of a table

thanks


If the table is named tabMain (<table id="tabMain">)

if (document.getElementById && document.getElementById("tabMain").style)
{
document.getElementById("tabMain").style.border = "1";
}
else alert("You need a better browser.");
You don't need "top" unless you're using frames, in which case you need
the frame name as defined in the frameset.

if (top.frames["frameName"].document.getElementById && top.frames
["frameName"].document.getElementById("tabMain").style)
{
top.frames["frameName"].document.getElementById
("tabMain").style.border = "1";
}
else alert("You need a better browser.");

-------------------------------------------------
~kaeli~
Jesus saves, Allah protects, and Cthulhu
thinks you'd make a nice sandwich.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
-------------------------------------------------
Jul 20 '05 #6
kaeli <in********************@NOSPAMatt.net> writes:
If the table is named tabMain (<table id="tabMain">)

if (document.getElementById && document.getElementById("tabMain").style)
{
document.getElementById("tabMain").style.border = "1";
That is unlikely to work, since "1" is not a valid CSS value for the
border property.
You don't need "top" unless you're using frames, in which case you need
the frame name as defined in the frameset.


The original poster wrote this "top.document.frmMain.tabMain.border". I
assume "frmMain" is a frame name. I.e., something like:

var frm = top.frames['frmMain'];
if (frm && frm.document.getElementById) {
var elem = frm.document.getElementById("tabMain");
if (elem && elem.style) {
elem.style.border = "1px solid black";
}
}

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #7
In article <3c**********@hotpop.com>, lr*@hotpop.com enlightened us
with...
kaeli <in********************@NOSPAMatt.net> writes:
If the table is named tabMain (<table id="tabMain">)

if (document.getElementById && document.getElementById("tabMain").style)
{
document.getElementById("tabMain").style.border = "1";


That is unlikely to work, since "1" is not a valid CSS value for the
border property.


How WOULD you set the border to 1? I stick to DIVs mostly, which would
be like...
document.getElementById("tabMain").style.border="t hin solid black";
I don't think that would set the borders for the cells, though, just the
table. It would look different than having border be "1" in the table
def...

-------------------------------------------------
~kaeli~
Jesus saves, Allah protects, and Cthulhu
thinks you'd make a nice sandwich.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
-------------------------------------------------
Jul 20 '05 #8
kaeli <in********************@NOSPAMatt.net> writes:
How WOULD you set the border to 1? I stick to DIVs mostly, which would
be like...
document.getElementById("tabMain").style.border="t hin solid black";
If you want to simulate the border attribute, the most likely way is:
document.getElementById("tabMain").border=1;
If that doesn't work, you can try:
document.getElementById("tabMain").setAttribute("b order","1");
I don't think that would set the borders for the cells, though, just the
table. It would look different than having border be "1" in the table
def...


Yes. I never used the border attribute, so I would go for a CSS solution:

<style type="text/css">
table {
border-collapse:collapse;
}
.borderTable td {
border: 1px solid black;
}
</style>

and then set the className instead of the border property:

document.getElementById("tabMain").className="bord erTable";

To remove the border, you would then do:

document.getElementById("tabMain").className="";

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #9
In article <u1**********@hotpop.com>, lr*@hotpop.com enlightened us
with...
kaeli <in********************@NOSPAMatt.net> writes:
Yes. I never used the border attribute, so I would go for a CSS solution:


Thanks!

-------------------------------------------------
~kaeli~
Jesus saves, Allah protects, and Cthulhu
thinks you'd make a nice sandwich.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
-------------------------------------------------
Jul 20 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Robert | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.