Log in

View Full Version : I'm looking for a code



ricki22
07-01-2012, 04:58 AM
Hello! all I have a website I'm looking for a code but I found nothing that could do it I'm not an expert but I'm doing a little bit.

I will explain one I can three links to diferent language such index.php? set_language = default and with two others over and I have a big image that are connected to a . css file like this who are the <div id="content_01">.

I am looking for a code that will change when I click on one of three languages ​​that'm worm picture on the link to the English language that image changes to English and if I click on the French language as image changes to Image French

but I'll link to better understand

I have 3 links its this

<a href="{url_page}?set_language=default"> src="{url_tmpl_main}img_1/lang1.gif" <img alt="" /> </ a>
<a href="{url_page}?set_language=spain"> src="{url_tmpl_main}img_1/lang2.gif" <img alt="" /> </ a>
<a href="{url_page}?set_language=french"> src="{url_tmpl_main}img_1/lang3.gif" <img alt="" /> </ a>


and for three of my index page picture her like this


<div id="content_01"> first image of the index page
<div id="content_02">
<div id="content_03">

and two other image that his link to my css file that I would change when I click on a link language to image the same language that I chose.

Its two days that I'm looking and I need your help.

Thank you in advance

bernie1227
07-01-2012, 08:38 AM
So youre saying, tha when you click the link for the different language, the image will change?

ricki22
07-01-2012, 02:42 PM
yes it's her when someone will click on the picture will change language ver another image that would be in English and if someone else clicks another language will change another image worm another image of that language,

Thank you for your help

bernie1227
07-02-2012, 07:09 AM
Here's some JavaScript which will change the src in the img tag, so:


function changeMySrc(i) {
if (i == 1) {
document.getElementById("Img1").src="Images/folder_open.gif";
document.getElementById("Img2").src="Images/folder.gif";
} else if (i == 2) {
document.getElementById("Img2").src="Images/folder_open.gif";
document.getElementById("Img1").src="Images/folder.gif";
}
}

Then just reference the function in the link that you want to click using an onclick event.

ricki22
07-02-2012, 01:58 PM
Thank you very much for your help :)

ricki22
07-02-2012, 02:48 PM
Hello! I am doing the test the way I do it's still not working I'm going to put my code back here and tell me if this is correct or not.

Thank you again for your help

ricki22
07-02-2012, 04:26 PM
Hello I made the test, but I always arrive at the same result when I click on my picture of the language but the link I and link worm picture but its not working is least if it was me who I'm doing it wrong 'm not an expert I can get a can here is the code I made a mistake when he told me how and I will do.


I but my link to my site and understanding the code above

http://www.citasyamigos.com/


<script>
function changeMySrc(i) {
if (i == 1) {
document.getElementById("http://www.citasyamigos.com/index.php").src="imagelangues/content-bg.jpg";
document.getElementById("http://www.citasyamigos.com/index.php?set_language=default").src="imagelangues/content-bg.jpg";

} else if (i == 2) {
document.getElementById("http://www.citasyamigos.com/index.php").src="imagelangues/encontent-bg.jpg";
document.getElementById("http://www.citasyamigos.com/index.php?set_language=default").src="imagelangues/encontent-bg.jpg";

}
}

</script>



thank you again for your support

keyboard
07-02-2012, 11:37 PM
On the images you want to change, (if there isn't already) add id="someIdHere"

Replace someIdHere with a value unique to each image.

For instance



<img src="elephant.png" alt="Elephant" id="elephantImage" />


Then, in the code bernie gave you, change Img1 and Img2 to the id's of your two images. and the src attribute, should be the path to the images.

THen, make your links look like this -

<a href="pathToSomething" onclick="changeMySrc('1');"></a>

bernie1227
07-03-2012, 12:21 AM
On the images you want to change, (if there isn't already) add id="someIdHere"

Replace someIdHere with a value unique to each image.

For instance



<img src="elephant.png" alt="Elephant" id="elephantImage" />


Then, in the code bernie gave you, change Img1 and Img2 to the id's of your two images. and the src attribute, should be the path to the images.

THen, make your links look like this -

<a href="pathToSomething" onclick="changeMySrc('1');"></a>

Oh yeah, sorry about that, didn't explain that well enough.

ricki22
07-03-2012, 02:05 AM
ok Thanks for your help I'll go try it I do not understand all my I think I will succeed with what you wrote me and said I'll be able.

Thank you again for your support :)