Results 1 to 8 of 8

Thread: [RESOLVED] div -background color

  1. #1

    Thread Starter
    Fanatic Member merhaba's Avatar
    Join Date
    Sep 2002
    Location
    Istanbul,Bartin-Gallipoli(Gelibolu-Canakkale)
    Posts
    601

    Resolved [RESOLVED] div -background color

    Hi,
    I am tring the change the background-color of a layer in every 10 seconds
    but get an error message...will you please fix the problem..?
    thanks
    VB Code:
    1. <html>
    2. <head>
    3. <script>
    4. var con=0;
    5. setInterval(" degis() ", 2000)
    6. function degis()
    7. {
    8. con++;
    9. document.getElementById("mytext").value=con
    10. if (con==5)
    11. {
    12. document.getElementById(" mydiv ").value=blue;
    13. }
    14. }
    15. </script>
    16. </head>
    17. <body>
    18. <div id=mydiv style="position:absolute;top:1;left:0; color:red;width:1020;height:120;z-index:-1;">
    19. hello there......
    20. </div>
    21. <form>
    22. <input type=text id="mytext" size=3 style="position:absolute;top:200;left:200;font-size:14pt;"><br><br>
    23. <input type=button value="print the nums..." style="position:absolute; top:400; left:200; onClick:'degis()';"><br><br>
    24. </form>
    25. </body>
    26. </html>
    Last edited by merhaba; Jan 12th, 2006 at 02:25 PM.

  2. #2
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,170

    Re: div -background color

    Is this what you want?
    Code:
    <html>
    <head>
    <script>
    var con=0;
    setInterval("degis()", 2000)
    function degis()
    {
    con++;
    document.getElementById("mytext").value=con
    if (con==5)
    {
    document.getElementById("mydiv").style.color="blue";
    }
    }
    </script>
    </head>
    <body>
    <div id=mydiv style="position:absolute;top:1;left:0; color:red;width:1020;height:120;z-index:-1;">
    hello there......
    </div>
    <form>
    <input type=text id="mytext" size=3 style="position:absolute;top:200;left:200;font-size:14pt;"><br><br>
    <input type=button value="print the nums..." style="position:absolute; top:400; left:200; onClick:'degis()';"><br><br>
    </form>
    </body>
    </html>

  3. #3

    Thread Starter
    Fanatic Member merhaba's Avatar
    Join Date
    Sep 2002
    Location
    Istanbul,Bartin-Gallipoli(Gelibolu-Canakkale)
    Posts
    601

    Re: div -background color

    Thanks Vbbit,
    but what you have done does not change the "background color"...
    it works only for the text...
    I still need help....

  4. #4
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,170

    Re: div -background color

    Change the line that is red to :

    document.getElementById("mydiv").style.background="blue";

    I hope this is exactly what you want

  5. #5

    Thread Starter
    Fanatic Member merhaba's Avatar
    Join Date
    Sep 2002
    Location
    Istanbul,Bartin-Gallipoli(Gelibolu-Canakkale)
    Posts
    601

    Re: div -background color

    ok thanks
    what about this ?
    How can I use a variable here?
    ...........................
    var anycolor;
    anycolor="red";
    document.getElementById("mydiv").style.color=anycolor;
    ...................................................

  6. #6
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,170

    Re: div -background color

    That should work and would give you a red background/text in 5 sec.

  7. #7

    Thread Starter
    Fanatic Member merhaba's Avatar
    Join Date
    Sep 2002
    Location
    Istanbul,Bartin-Gallipoli(Gelibolu-Canakkale)
    Posts
    601

    Re: div -background color

    well done vbbit,
    it works


    Thank you...

  8. #8

    Thread Starter
    Fanatic Member merhaba's Avatar
    Join Date
    Sep 2002
    Location
    Istanbul,Bartin-Gallipoli(Gelibolu-Canakkale)
    Posts
    601

    Re: [RESOLVED] div -background color

    document.getElementById("mydiv").style.backgroundColor=mycolor;
    this works ,too

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width