I’m very new to JavaScript and I have a problem with the following:
[FONT=Courier New] function albums() {[/FONT][INDENT][FONT=Courier New] …
xrequest.onreadystatechange = function() {[/FONT][INDENT][FONT=Courier New] if ( xrequest.readyState == 4 ) {[/FONT][INDENT][FONT=Courier New] if ( xrequest.status == 200 ) {[/FONT][INDENT][FONT=Courier New] …
for (var i = 0; i < xrows.length; i++) {[/FONT][INDENT][FONT=Courier New] var album = document.createElement(‘img’);
album.src = …
album.alt = xrows*.getAttribute(‘album_name’);
album.id = xrows*.getAttribute(‘album_id’);
document.getElementById(‘albums’).appendChild(album);
album.addEventListener(‘click’, function() { album(this.id); }, false);
[/FONT] [/INDENT][FONT=Courier New]}
[/FONT] [/INDENT][FONT=Courier New]}
[/FONT] [/INDENT][FONT=Courier New]}
[/FONT] [/INDENT][FONT=Courier New]}
[/FONT] [/INDENT][FONT=Courier New]}
function album(id) { alert(id); }[/FONT]
It doesn’t work. And rightfully so, of course. My question is, how do I access the album function?
Any help would be greatly appreciated; thank you for your time.