superhaine
New Member
I'm currently writing a website with a friend and I need to create a javascript loop for pulling images out of a database and populating them in xy positions on a grid.The database we're using is built in python and django but for now I'm trying to get it working with one loop and a test image.This is the loop in question:\[code\]function createImages(){ var picture = document.createElement('img');{ for (var pic=0; pic < 100; pic++) { pic.pk = 1; pic.model = 'image'; pic.fields.title = 'Image Test'; pic.fields.timestamp = '2013-01-01T00:00:00.000Z'; pic.fields.image = 'http://i240.photobucket.com/albums/ff301/quyenhiepkhach/CAT.jpg'; pic.fields.height = 30 + 'px'; pic.fields.width = 30 + 'px'; pic.fields.link = '#ImageLink'; pic.fields.board = 1; pic.fields.posx = 100 + 'px'; pic.fields.posy = 50 + 'px'; pic.fields.owner = 1; pic.fields.region = 1; picture.className = 'image-tooltip'; picture.src = http://stackoverflow.com/questions/14538206/pic.fields.image; picture.style.marginTop = pic.fields.posy; picture.style.marginLeft = pic.fields.posx; picture.style.height = pic.fields.height; picture.style.width = pic.fields.width; document.body.appendChild(picture); } }};createimages();\[/code\]What I have working so far:
- Grid that is drawn onto my index page with two sections (prime andstandard).
- Mouseover script that displays the xy coords and standard or primegridspace. (not working in jsfiddle)
- Javascript loop for pulling images out of database and writing them to body of page
- Mouseover script to display some of the image data