Alternating colours in a table cell

Discussion in 'Javascript' started by Trev, Nov 7, 2006.

  1. Trev

    Trev Guest

    Is there any way to make table cell's bgColor alternate, simulating a
    flashing effect?
     
    Trev, Nov 7, 2006
    #1
    1. Advertising

  2. Trev wrote:
    > Is there any way to make table cell's bgColor alternate, simulating a
    > flashing effect?


    Yes.

    Richard.
     
    Richard Cornford, Nov 7, 2006
    #2
    1. Advertising

  3. Trev

    Trev Guest

    Richard Cornford wrote:
    > Trev wrote:
    > > Is there any way to make table cell's bgColor alternate, simulating a
    > > flashing effect?

    >
    > Yes.
    >
    > Richard.


    please elaborate!!!!
     
    Trev, Nov 7, 2006
    #3
  4. Trev wrote:
    > Richard Cornford wrote:
    >> Trev wrote:
    >>> Is there any way to make table cell's bgColor alternate, simulating a
    >>> flashing effect?

    >>
    >> Yes.
    > >
    > > Richard.

    >
    > please elaborate!!!!


    An ability to use scripts to apply specific background colors to
    individual table cells implies an ability to alternate the colours
    used, both sequentially and with time.

    Richard.
     
    Richard Cornford, Nov 7, 2006
    #4
  5. Trev

    ASM Guest

    Trev a écrit :
    > Is there any way to make table cell's bgColor alternate, simulating a
    > flashing effect?
    >


    Arrrghhh ! beurk !

    <td id="flashy" style="background:lime">


    javascript in head :

    onload = function() {
    setInterval( function() {
    var flsh = document.getElementById('flashy').style;
    flsh.background = flsh.background=''? 'yellow' : '';
    }, 100);
    }
     
    ASM, Nov 7, 2006
    #5
  6. Trev

    Trev Guest

    Richard Cornford wrote:
    > Trev wrote:
    > > Richard Cornford wrote:
    > >> Trev wrote:
    > >>> Is there any way to make table cell's bgColor alternate, simulating a
    > >>> flashing effect?
    > >>
    > >> Yes.
    > > >
    > > > Richard.

    > >
    > > please elaborate!!!!

    >
    > An ability to use scripts to apply specific background colors to
    > individual table cells implies an ability to alternate the colours
    > used, both sequentially and with time.
    >
    > Richard.



    Is there any way to implement this in Javascript, and if so, how?
    I have tried using a while(true) loop using the <td>'s element name and
    changing bgColor but the code has a malaise.
     
    Trev, Nov 7, 2006
    #6
  7. Trev

    ASM Guest

    Richard Cornford a écrit :
    > Trev wrote:
    >> Richard Cornford wrote:
    >>> Trev wrote:
    >>>> Is there any way to make table cell's bgColor alternate, simulating a
    >>>> flashing effect?
    >>> Yes.
    >>>
    >>> Richard.

    >> please elaborate!!!!

    >
    > An ability to use scripts to apply specific background colors to
    > individual table cells implies an ability to alternate the colours
    > used, both sequentially and with time.
    >
    > Richard.


    :)

    well seen !
     
    ASM, Nov 7, 2006
    #7
  8. Trev

    Trev Guest

    Tried it...still some malaise.... :(

    <HTML>
    <HEAD onload = function() {
    setInterval( function() {
    var flsh = document.getElementById('flashy').style;
    flsh.background = flsh.background=''? 'yellow' : '';
    }, 100);
    } >

    </HEAD>
    <BODY>



    <table>
    <tr><td id="flashy" style="background:lime">whizz</td><td>eggy
    xt</td><td>bang</td></tr>
    </table>

    </BODY>


    </HTML>
     
    Trev, Nov 7, 2006
    #8
  9. Trev

    ASM Guest

    Trev a écrit :
    > Tried it...still some malaise.... :(


    I said in *javascript* ! ...

    (in header)

    You don't know how to input a script code in a html file ?
     
    ASM, Nov 7, 2006
    #9
  10. Trev

    Trev Guest

    ASM wrote:
    > Trev a écrit :
    > > Tried it...still some malaise.... :(

    >
    > I said in *javascript* ! ...
    >
    > (in header)
    >
    > You don't know how to input a script code in a html file ?



    Damn, sorry, my mind slipped on a dog turd.
     
    Trev, Nov 7, 2006
    #10
  11. Trev

    Trev Guest

    Trev wrote:
    > ASM wrote:
    > > Trev a écrit :
    > > > Tried it...still some malaise.... :(

    > >
    > > I said in *javascript* ! ...
    > >
    > > (in header)
    > >
    > > You don't know how to input a script code in a html file ?

    >
    >
    > Damn, sorry, my mind slipped on a dog turd.


    By the way, why is onload in the head? Should it be in the body tag:
    <body onLoad='function();'> ??
     
    Trev, Nov 7, 2006
    #11
  12. Trev

    ASM Guest

    Trev a écrit :
    > Trev wrote:
    >> ASM wrote:
    >>> Trev a écrit :
    >>>> Tried it...still some malaise.... :(
    >>> I said in *javascript* ! ...

    >>
    >> Damn, sorry, my mind slipped on a dog turd.

    >
    > By the way, why is onload in the head?


    why not ?

    > Should it be in the body tag:
    > <body onLoad='function();'> ??


    <body
    onload="setInterval( function() {
    var flsh = document.getElementById('flashy').style;
    flsh.background = flsh.background=''? 'yellow' : '';
    }, 100);">

    not very clean
     
    ASM, Nov 7, 2006
    #12
  13. Trev

    PL Guest

    PL, Nov 7, 2006
    #13
  14. Trev

    Randy Webb Guest

    PL said the following on 11/7/2006 3:25 PM:
    > Trev wrote:
    >
    >> Is there any way to make table cell's bgColor alternate, simulating a
    >> flashing effect?

    >
    >
    > Hi Trev,
    > If you want some ideas, have a look at my webpage (see below).


    Before the page even loads:

    Line: 638
    Char: 1
    Error: Access is Denied
    Code: 0
    URL: http://www.btinernet.com/~dr_paul_lee/

    Not very convincing proof of an author's ability to write Javascript.

    --
    Randy
    Chance Favors The Prepared Mind
    comp.lang.javascript FAQ - http://jibbering.com/faq
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
     
    Randy Webb, Nov 7, 2006
    #14
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Amirallia

    How Do I Print Table Cell Colours?

    Amirallia, Jan 27, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    526
    teknohippy
    Jan 27, 2005
  2. Ralph Snart
    Replies:
    2
    Views:
    793
    Ralph Snart
    Aug 3, 2003
  3. Massimo Capetola

    How Do I Print Table Cell Colours?

    Massimo Capetola, Sep 28, 2004, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    114
    Robert Koritnik
    Sep 29, 2004
  4. Amirallia

    How Do I Print Table Cell Colours?

    Amirallia, Jan 27, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    111
    Amirallia
    Jan 27, 2005
  5. Peter Williams
    Replies:
    3
    Views:
    211
Loading...

Share This Page