SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2001
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    functions & rollovers

    ill try to explain as clear as i can(which might not be too good)

    how do you pass an argument to a function.


    for example if you have a <span id = "test" onMouseOver ="myfunc(x)>

    eg you have lots of differant span id's but you want then all to have a certain background-color with each individual on mouseover event without having to write separate code for each span id
    eg <span id=" test2"onmouseover ="this.style.background ='red'>


    cheers chris

  2. #2
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Multiples

    Well you could build up an javascript "hash":

    var elements=new Array('cat','dog','mouse','moose');
    var colors =new Array('red','green','orange','blue');

    for i (0..elements.length){
    eval ('var '+elements[i]+' = '+colors[i]);
    }

    function switch(){
    var eRef=document.window.event.srcElement;
    eRef.style.backgroundColor=eval(eRef.id);
    }

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---


Bookmarks

Posting Permissions

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