Hi,

I am trying to code a game program in js that will allow the user to click on a "Roll Dice" button that calls a js function to randomly display various images of dice. My problem is that I cant find a way to display the images where I want. The only way so far I know is to use document.write but that creates a new page that displays only the image(s). What I want is for the images to appear in a certain cell of a table. This seems like it should be fairly easy to do but I cant find any information on the web.. Please help!

Kadjii,

In a nutshell, you serve the page with <img> tags in all relevant table cells. Then, in response to whatever events, javascript changes the images by dynamically setting the <img>'s src.

Advice abounds. Search the web for "DHTML image replacement" or "javascript image replacement".

Airshow

Alternatly you could pop in img-tags where you want, but this tends to get messy. You could use javascript to fetch the correct column of the table and then simply insert a img.

Thanks for the info, I finally got it working. And I see now that I have 2 options for doing this

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.