I have a website that has multiple languages, currently the language bar is displayed along the top of the site with a button for each language. What I would prefer is one button, click it once, the button image changes to a union jack flag, and english is called, press it again, and the button image changes to french, and the french language is called, etc etc..
Is this one button, multiple calls possible? can anyone give me a good place to start looking in to this?
Yes, it is possible.
Your
htmlwould look something like this:(Remember to set this to your default to begin with)
and your javascript:
If you ever need another language, just add it to the switch.
Alternatively, change the case code to:
And remove the line that says
buttonDetails.innerHTML = "";if all you want is an image.To call a function to change the language you would simply add a function call to one of your switch cases like so: