Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Dec 2002
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help with a script please!

    This is probably something really simple I'm missing out as I'm hardly a javascript expert but i'm having difficulties creating a script on my webpage.

    Its a real simple script, I am designing a navigation menu and i want the background of each item on the menu to change color onmouseover. I've tried doing this in two ways:

    1) using an onmouseover in the <td> tag of my menu table:

    <td onmouseover="javascript:this.bgcolor=colors[0]>

    colors is an array I have set within the head tags of my webpage, I have also tried putting in a color and hex value and still the background will not change color. This should be really simple i've used it before and if only i could get to a computer at colllege i could work it out!

    2) I have used <span> tags and used a script to try and alter the background-color in style. When i do this i keep getting syntax errors where i use the '-' symbol in my script.

    Can any give me any idea of where i'm goin wrong? This is driving me mad! If there is a better or easier way of doin this then I would be grateful for some ideas. I am using IE6 and ultimatley will be enhancing the script to include a color fade onmouseover but for now I'm just stuck with the simple begginings!

    Any help will be greatly appreciated

  • #2
    Regular Coder
    Join Date
    Sep 2002
    Location
    Louisiana
    Posts
    576
    Thanks
    0
    Thanked 0 Times in 0 Posts
    this should do the job, but...
    <td onmouseover="javascript:this.style.background='blue'>
    it will be more difficcult to get it to do it with that color array, try this
    Code:
    function test(loc) {
    loc.style.background = colors[0];
    }
    <td onmouseover="javascript:test(this)">
    Last edited by chrismiceli; 12-21-2002 at 03:49 PM.

  • #3
    New to the CF scene
    Join Date
    Dec 2002
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks a lot mate! the second bit works a treat!

    Would the easiest way 2 make a fade be to use setTimeout and make the script go through all the colours in my array?


  •  

    Posting Permissions

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