I've torn all of my hair out trying to figure this out. I am trying to use Javascript to load an image and display it in a div. It works just fine when I use an absolute for the file name. When I try to use a variable, it does nothing. When I trace the variable, it does contain the correct value. I'm stumped.
Thanks. Unfortunately I figured that out and there is a whole other problem.
The variable $image does iterate properly. However, whichever button I hit, it always displayed ../maps/1.gif even though the file name (which corresponds with the id should change with each listing.
Here's where it gets weird. I deleted that file, and put another one in it's place. So now there is a different image in ../maps/1.gif. It still displays the image that was there before, even though it's been deleted. I went to another browser and did the test, and it took the new first image. I went back, re-opened Firefox, and it still displays the deleted image.
If you're still using the code above then I don't see how it's supposed to work, there are a couple of static id fields (all id's in a document should always be unique), so how does it know which image to show?
Your other problem just sounds like a caching issue.
If you have the site available online, it would be easier to problem solve. Otherwise you could also just post the result of what PHP produces.
Sorry for disappearing. I had to take a break from this before I lost my mind. The cache is not the issue. Which is good, because I can only fix this on my own computer. Whatever.
The id problem is solved because the entire listing is in a php foreach loop. For each listing it pulls the information to display (name, address, etc) and an id number. The id number also corresponds to the name of the image file.
When I trace the id, it works. When I trace the variable that I am using that includes the path and filename, it works. But when I hit the button, it does not display the correct image. It's a little baffling, because at that point in the program the variable that represents the filename is correct. So I don't know why when I use the variable, it doesn't pull the right image.
One small issue that I don't know if it can be fixed...
When you hit the button on listing #1, the right map comes up. If you then hit the button for listing #2, the right map takes its place. This works for everything, as long as you are hitting the button for a listing that has a HIGHER id than the one you pressed before. If you try to hit #4 after you hit #5, it doesn't work. Any thoughts?
I'm not sure of what your recordset looks like. I am assuming that $name['id'] is the primary key for that entry, but if not then we should use something else as each id in the document needs to be unique for this to work properly.
I dont suppose you can post the structure of $datas so I can see?
I'd be happy to post the structure of $datas, but I'm not entirely sure what you mean. Are you looking for the myPhp database structure? What does print_r($datas); do?
For my testing I was using data that looks like this (print_r):
Code:
Array
(
[0] => Array
(
[id] => 1
[state] => PA
[name] => name
[site] => site
[description] => description
[street] => street
[city] => city
[zip] => zip
)
[1] => Array
(
[id] => 2
[state] => PA
[name] => name
[site] => site
[description] => description
[street] => street
[city] => city
[zip] => zip
)
)
There are still a few validation issues like you have the ids "link" and "trailmap" that would be written out per entry.
If you are using them for styling then I suggest changing them to a class instead.
Link is used as a piece of data (I need that as the display part of the <a href
Trailmap will probably be deleted. I think I set that up for a feature that I want to add later.
I really appreciate all of this help. I've been working in Php for just a couple of weeks and I've never used JavaScript or JQuery before I started this a few days ago. Since I had to drop out of school, not having an instructor to ask is just about killing me. I'm so grateful for communities like this.
Bookmarks