Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
46
rated 0 times [  50] [ 4]  / answers: 1 / hits: 24382  / 10 Years ago, sun, august 31, 2014, 12:00:00

I have one image (img.png), with its content changing after a combo box changes.



The problem is the content of the image doesn't change when I change the combo box on the page.



I tried to use JavaScript like this:



function SwitchPic(pic) {
pic.src = img.png;
}


and the img tag is:



<img src='img.png' id='img1' name='img1'>


and the combo box tag is:



<select name=users onchange=show(this.value);SwitchPic(img1);>
<option value=>Select a Number:</option>
<option value=a>a</option>
<option value=b>b</option>
<option value=c>c</option>
</select>


It worked the first time I change the option, but when I re-change the option, it keeps the image without changing it.



How can I solve this?


More From » html

 Answers
37

Might be just a cache problem



Instead of just using the filename, add a random part to it, like 'img.png?random', that way you'll force the browser to look for the image again on the server, but the ?random part will be discarded anyway and the file will still be found



Easiest way to do this is to add the date/time after the extension


[#69606] Wednesday, August 27, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
serena

Total Points: 488
Total Questions: 125
Total Answers: 114

Location: Estonia
Member since Wed, Jun 8, 2022
2 Years ago
;