Jump to content

Recommended Posts

Hi

Im trying to stack images on top of each other with a dropdown list, however all i can do is replace them.

Is this possible with js and can i load them into empty div's ?

 

<SCRIPT>

// preload images

var img1 = new Image().src = "/images/jht.gif"

var img2 = new Image().src = "/images/jsht.gif"

var img3 = new Image().src = "/images/pht.gif"

 

function setImage(imageSelect) {

theImageIndex = imageSelect.options[imageSelect.selectedIndex].value;

if (document.images)

    document.images[0].src = eval("img" + theImageIndex);

  }

</SCRIPT>

 

</HEAD><BODY>

 

<FORM NAME="theForm" METHOD="POST">

<div>Images:

<SELECT NAME="items" onChange="setImage(this)">

  <OPTION VALUE="1">Image 1

  <OPTION VALUE="2">Image 2

  <OPTION VALUE="3">Image 3

</SELECT>

</div>

<div id="far"><IMG SRC = "/images/base_image.gif" ></div>

</FORM>

 

</BODY>

Link to comment
https://forums.phpfreaks.com/topic/146677-image-overlay-possible/
Share on other sites

Yes, you can stack images on top of each other, you would use layers in CSS, but why? If the images aren't transparent so you can see through them, then you can only see the top image (or at worst you would see edges of the lower images sticking out from the top). It would be simpler to just swap out the image on the top.

 

If it is an issue of a time delay to display the changed image, then just load all the images and change the display properties.

 

Can you give a little more explanation as to what you are trying to acheive and the problem with the code you posted above?

I want to create a preview of what a t-shirt would look like with a print on it.

 

so you have an image .. a red t-shirt say and then you can add a design over it, a gif or png (im not interested in IE)

 

I was thinking of doing this in flash, but js seemed to be simpler :s !

 

the code i added replaces the image on selecting an item from the dropdown, but i want them on top of each other.

 

Idealy loaded in another div, then i can control the position and depth with css.

 

thanks

 

I want to create a preview of what a t-shirt would look like with a print on it.

 

so you have an image .. a red t-shirt say and then you can add a design over it, a gif or png (im not interested in IE)

 

I was thinking of doing this in flash, but js seemed to be simpler :s !

 

the code i added replaces the image on selecting an item from the dropdown, but i want them on top of each other.

 

Idealy loaded in another div, then i can control the position and depth with css.

 

thanks

 

 

Hmm... how are the shirts themselves loaded?  Because IMO the simplest solution (without knowing how the rest of your system works) would be to set the shirt image as the background image for the element, then have the shirt design/logo that's selected by the dropdown fill the content of that element.  Since the shirt image is set as the background, you should get your overlay effect.

the tshirts are loaded from a db, so theres not much chance of adding them to the background image.

 

I would also like to add more than one image to the images stack, eg. print, buttons, logo

 

so i have to load an image into a specific div on the page.

 

any thoughts?

 

thanks

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.