change images in js

Discussion in 'JavaScript' started by Alidad, Jan 14, 2010.

  1. #1
    Hi, this is relate to switch images, let say that i have two php files, and each files has one images called (red-images.png and yellow-images.png).

    I'm trying to create switch program in php using two buttons of (red and yellow) buttons, and any time i click on that of those two buttons it will change images.

    I'm using included statments
    (<?php include(); ?>)
    Code (markup):
    to put
    <?php include('yellow.php'); ?>or <?php include('red.php'); ?>.
    Code (markup):
    My question is that how do i can write that in javascripts and php code to allow to develop switch images buttonsbetween red.php or yellow.php in index.php page using two of those buttons using
    <?php include(); ?>!
    Code (markup):
    please help thanks.

    AM
     
    Alidad, Jan 14, 2010 IP
  2. s_ruben

    s_ruben Active Member

    Messages:
    735
    Likes Received:
    26
    Best Answers:
    1
    Trophy Points:
    78
    #2
    Can I see the codes of the files red.php or yellow.php?? And why you want to do it by include()??
     
    s_ruben, Jan 15, 2010 IP
  3. Alidad

    Alidad Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    hi, sorry maybe i use wrong code of (included) statments, but what i'm trying to do is that when i have two images that saved in other files called "image1.jpg and images2.jpg.) both images are same images the different is colors.

    however, in index.php page, when i have two button of red and yellow, and when i click on red button it wills how image1.jpg and and blue button it will show image2.jpg.

    so if i clicked on red red button and show image1.jpg and if i re-refreshe same page or press F5 to refreshe it, then it need show same images of image1.jpg...

    how can do develop that in javascripts!

    please help thanks.

    AM
     
    Alidad, Jan 15, 2010 IP
  4. s_ruben

    s_ruben Active Member

    Messages:
    735
    Likes Received:
    26
    Best Answers:
    1
    Trophy Points:
    78
    #4
    I think you have to use cookies for it!! Can I see the script?
     
    s_ruben, Jan 16, 2010 IP
  5. ajith107

    ajith107 Peon

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hi Alidad,
    check this.
    1.Create a folder images and save the red, yellow images.
    Run the attached file, i think this will work for you.
     

    Attached Files:

    ajith107, Jan 18, 2010 IP