Killer0292 Posted June 12, 2009 Report Posted June 12, 2009 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 Quote
administrator Posted July 3, 2009 Report Posted July 3, 2009 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 Quote
administrator Posted July 3, 2009 Report Posted July 3, 2009 Another option is to use PHP and to do this on the server. It pretty much works in the same way except you will have to pass the zip code selected to PHP via either: - get/post request - ajax transaction. You can learn a little about Ajax here: http://www.killerajax.com/ Stefan Quote
Recommended Posts
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.