How to change table border from javascript?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Harry

    How to change table border from javascript?

    Whats wrong with this?

    top.document.fr mMain.tabMain.b order = "1";

    thanks


  • Richard Cornford

    #2
    Re: How to change table border from javascript?

    "Harry" <a@abc.com> wrote in message
    news:A1alb.1239 $JM4.12303453@n ews-text.cableinet. net...[color=blue]
    > Whats wrong with this?
    >
    > top.document.fr mMain.tabMain.b order = "1";[/color]

    It has no context.

    Richard.


    Comment

    • Harry

      #3
      Re: How to change table border from javascript?

      how would I do it then? - what am I missing?

      thanks

      "Richard Cornford" <Richard@litote s.demon.co.uk> wrote in message
      news:bn3ebe$h0m $1$8302bc10@new s.demon.co.uk.. .[color=blue]
      > "Harry" <a@abc.com> wrote in message
      > news:A1alb.1239 $JM4.12303453@n ews-text.cableinet. net...[color=green]
      > > Whats wrong with this?
      > >
      > > top.document.fr mMain.tabMain.b order = "1";[/color]
      >
      > It has no context.
      >
      > Richard.
      >
      >[/color]


      Comment

      • kaeli

        #4
        Re: How to change table border from javascript?

        In article <n8blb.1288$F_4 .12451872@news-text.cableinet. net>, a@abc.com
        enlightened us with...[color=blue]
        > how would I do it then? - what am I missing?
        >[/color]

        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.


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

        Comment

        • Harry

          #5
          Re: How to change table border from javascript?

          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" <infinite.possi bilities@NOSPAM att.net> wrote in message
          news:MPG.19feff dd705b8d3b9898f 4@nntp.lucent.c om...[color=blue]
          > In article <n8blb.1288$F_4 .12451872@news-text.cableinet. net>, a@abc.com
          > enlightened us with...[color=green]
          > > how would I do it then? - what am I missing?
          > >[/color]
          >
          > 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
          > -------------------------------------------------[/color]


          Comment

          • kaeli

            #6
            Re: How to change table border from javascript?

            In article <2dclb.1362$JO5 .13079712@news-text.cableinet. net>, a@abc.com
            enlightened us with...[color=blue]
            > 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
            >[/color]

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

            if (document.getEl ementById && document.getEle mentById("tabMa in").style)
            {
            document.getEle mentById("tabMa in").style.bord er = "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.getEl ementById && top.frames
            ["frameName"].document.getEl ementById("tabM ain").style)
            {
            top.frames["frameName"].document.getEl ementById
            ("tabMain").sty le.border = "1";
            }
            else alert("You need a better browser.");

            -------------------------------------------------
            ~kaeli~
            Jesus saves, Allah protects, and Cthulhu
            thinks you'd make a nice sandwich.


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

            Comment

            • Lasse Reichstein Nielsen

              #7
              Re: How to change table border from javascript?

              kaeli <infinite.possi bilities@NOSPAM att.net> writes:
              [color=blue]
              > If the table is named tabMain (<table id="tabMain">)
              >
              > if (document.getEl ementById && document.getEle mentById("tabMa in").style)
              > {
              > document.getEle mentById("tabMa in").style.bord er = "1";[/color]

              That is unlikely to work, since "1" is not a valid CSS value for the
              border property.
              [color=blue]
              > You don't need "top" unless you're using frames, in which case you need
              > the frame name as defined in the frameset.[/color]

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

              var frm = top.frames['frmMain'];
              if (frm && frm.document.ge tElementById) {
              var elem = frm.document.ge tElementById("t abMain");
              if (elem && elem.style) {
              elem.style.bord er = "1px solid black";
              }
              }

              /L
              --
              Lasse Reichstein Nielsen - lrn@hotpop.com
              Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
              'Faith without judgement merely degrades the spirit divine.'

              Comment

              • kaeli

                #8
                Re: How to change table border from javascript?

                In article <3cdmcsdj.fsf@h otpop.com>, lrn@hotpop.com enlightened us
                with...[color=blue]
                > kaeli <infinite.possi bilities@NOSPAM att.net> writes:
                >[color=green]
                > > If the table is named tabMain (<table id="tabMain">)
                > >
                > > if (document.getEl ementById && document.getEle mentById("tabMa in").style)
                > > {
                > > document.getEle mentById("tabMa in").style.bord er = "1";[/color]
                >
                > That is unlikely to work, since "1" is not a valid CSS value for the
                > border property.[/color]



                How WOULD you set the border to 1? I stick to DIVs mostly, which would
                be like...
                document.getEle mentById("tabMa in").style.bord er="thin 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.


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

                Comment

                • Lasse Reichstein Nielsen

                  #9
                  Re: How to change table border from javascript?

                  kaeli <infinite.possi bilities@NOSPAM att.net> writes:
                  [color=blue]
                  > How WOULD you set the border to 1? I stick to DIVs mostly, which would
                  > be like...
                  > document.getEle mentById("tabMa in").style.bord er="thin solid black";[/color]

                  If you want to simulate the border attribute, the most likely way is:
                  document.getEle mentById("tabMa in").border=1 ;
                  If that doesn't work, you can try:
                  document.getEle mentById("tabMa in").setAttribu te("border","1" );
                  [color=blue]
                  > 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...[/color]

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

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

                  and then set the className instead of the border property:

                  document.getEle mentById("tabMa in").className= "borderTabl e";

                  To remove the border, you would then do:

                  document.getEle mentById("tabMa in").className= "";

                  /L
                  --
                  Lasse Reichstein Nielsen - lrn@hotpop.com
                  Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
                  'Faith without judgement merely degrades the spirit divine.'

                  Comment

                  • kaeli

                    #10
                    Re: How to change table border from javascript?

                    In article <u162b7ru.fsf@h otpop.com>, lrn@hotpop.com enlightened us
                    with...[color=blue]
                    > kaeli <infinite.possi bilities@NOSPAM att.net> writes:
                    >
                    >
                    > Yes. I never used the border attribute, so I would go for a CSS solution:
                    >[/color]

                    Thanks!

                    -------------------------------------------------
                    ~kaeli~
                    Jesus saves, Allah protects, and Cthulhu
                    thinks you'd make a nice sandwich.


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

                    Comment

                    Working...