Jump to content

Conditional display of images on website


Killer0292

Recommended Posts

Hi,

 

I'm currently learning to create web pages using Dreamweaver and have also written some Javascript to read and interpret a post(zip)code. My problem is that I want to display different images depending on the post(zip)code and it's not obvious to me how you do this. There will also be a different number of images that are post(zip)code dependent. I would want the first image to be placed top left of the page, the next to its right, the next to its right, etc. Can anyone point me to the construct that will allow me to do this? I'm not looking for any actual code as finding out how to do things is half the fun; I just need pointing in the right direction.

 

Regards,

 

Tony

Link to comment
Share on other sites

  • 3 weeks later...

You can do this with Javascript and DOM scripting. You would have to load your collection of zip codes into say a Javascript associative array, where you would pair up your zip codes to images.

 

Once a zip code is selected, you could loop through your array and then use the DOM to set display the image.

 

Hint: Look at 'innerHTML'.

 

Try it with a simple array first and then expand from there.

 

Stefan

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...