View Single Post
  #1 (permalink)  
Old March 1st, 2007, 08:29 AM
schoolBoy schoolBoy is offline
Authorized User
 
Join Date: Mar 2007
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default send variable in function to another function

Hi people,
I have to make a assignment for school.
I have to make the same as on this website http://www.airtightinteractive.com/p...iewer/example/

only then in JavaScript ( cause the example website did it in flash )
So I have the folowing code:
function showPictures()
    {
        for(var i = 0; i < album.length; i++)
        {
            var mijnImg = document.createElement("img")
            mijnImg.setAttribute("src", album[i].url)
            mijnImg.setAttribute('width','200px');
                       mijnImg.setAttribute('height','200px');
        mijnImg.setAttribute("onClick", "vergrootImg()");
            mijnImg.style.margin = '40px'
            mijnImg.setAttribute('border', 5);
            mijnImg.style.borderColor = 'white'
    document.getElementById("fotoalbum").appendChild(m ijnImg)
        }
    }

and the function:
        function vergrootImg()
    {
        mijnImg.setAttribute('width','400px');
        mijnImg.setAttribute('height','400px');
    }

My question is about the onClick thats defined in the showPictures() function.
It sais that when a picture is clicked it should change the width and height defined in the " vergrootImg() " function.

But it doesnt work.
I think the vergrootImg function doesnt know what " mijnImg " is
cause he variable is only local in the other function ?

so how do I sent this variable to the other function

thnx for reading my question,
Martin