Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
english & French page (remember last visited page)
Old 06-02-2010, 07:13 PM english & French page (remember last visited page)
Junior Talker

Posts: 1
Name: wellington
Trades: 0
Hello Everyone!!

- I have a page English & French

- I want my visitors once they select ENGLISH on the radio button to remember that whenever they visit my site.

> I do have the javascript code 100% right but I'm not sure how to store in the cookie when someone clicks the radio button.


HTML File that I tested but didn't work...PLEASE HELPPPP!!!
----------
<body onload="checkCookie()">
<form id="c_name">
<input type="radio" name="choice" value="languageEN" onClick="location.href='en.html'">English<br />
<input type="radio" name="choice" value="languageFR" onClick="location.href='fr.html'">French<br />
</form>
-----------------


/* JAVA SCRIPT FILE (100% correct)*/

function setCookie(c_name,value,expiredays,path) {
var exdate = new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie = c_name+ "=" +escape(value)+ ((expiredays==null) ? "" : ";expires=" +exdate) + ((path==null) ? "" : ";path=" +path);

}



function checkCookies(c_name) {
var value = "";
if (document.cookie.length > 0) {
c_start = document.cookie.indexOf(c_name + "=");

if (c_start != -1) {
c_start = c_start + c_name.length + 1;
c_end = document.cookie.indexOf(";",c_start);
if (c_end == -1) c_end = document.cookie.length;
value = unescape(document.cookie.substring(c_start,c_end)) ;
if (value == "languageFR") window.location = "/fr.html";
else window.location = "/en.html";
}
}
}

--------------------------

function switchLang() {
var url = document.location.href;
if (url.indexOf("en.html") != -1) {
setCookie('helloooo','languageFR', 365,'/');
window.location = url.replace(/en.html/, "fr.html");
}

if (url.indexOf("fr.html") != -1) {
setCookie('helloooo','languageEN', 365,'/');
}
}
well00 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-03-2010, 09:19 AM Re: english & French page (remember last visited page)
Super Talker

Posts: 139
Name: John Davis
Trades: 0
This is unrelater set of strings.

onload action is is happen only once, right after page loaded.
But you have to use onClick for your radios.

The function switchLang is never performed
Function checkCookies is defined, but checkCookie is used.

So, I guess you wrong, you JS code is not 100% right.
__________________
»
Please login or register to view this content. Registration is FREE
- Interactive maps for websites
»
Please login or register to view this content. Registration is FREE
for web developers
MapMaster is offline
Reply With Quote
View Public Profile Visit MapMaster's homepage!
 
Reply     « Reply to english & French page (remember last visited page)
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.19445 seconds with 12 queries