Change image on Same PHP page

agroup

New Member
Messages
190
Reaction score
0
Points
0
Hi

i am working on a script. i am creating a script page.
i want to show a pic on the page and have to give some links of other images

so that the user click on the link and the image change without changing page.

in other words the image change and the page remain same.

Can you help me?

I need this urgently . Thanx
 
Last edited:

mephis

New Member
Messages
39
Reaction score
0
Points
0
you'll need to use javascript to do that.

example:
Code:
<div id="main_image">
    <img id="my_image" src="image1.jpg" />
</div>
<div id="thumbs">
    <img src="thumb2.jpg" onClick="change_image('image2.jpg')" />
    <img src="thumb3.jpg" onClick="change_image('image3.jpg')" />
    <img src="thumb4.jpg" onClick="change_image('image4.jpg')" />
</div>
<script language="javascript">
function change_image(img) {
    document.getElementById('my_image').src = img;
}
</script>
(I'm pretty certain this code will work, but give it a try first)
 

xav0989

Community Public Relation
Community Support
Messages
4,467
Reaction score
95
Points
0
As mephis said, the only way to do what you asked is through javascript/AJAX.
BTW, the code you typed looks pretty valid to me!
 

leafypiggy

Manager of Pens and Office Supplies
Staff member
Messages
3,819
Reaction score
163
Points
63
xav0989, why do you point out the obvious? you don't need to restate something someone has already said. I've seen you do it a lot lately, and its very annoying.
 
Top