One page with 2 button and one checkbox, if you press one of the button, it redirects you to the selected option. If the check box is checked, a cookie is stored so that when the user come back, there's something that knows what he pressed.
let's post my index.php
<html> <head> <script language="Javascript1.2" src="functions.js" type="text/javascript"> </script> <script language="Javascript1.2" src="lang_check.js" type="text/javascript"> </script> </head> <body> <script language="javascript"> document.cookie </script> <form name="langButton" onsubmit="return check_pressed_button();" > <input type="submit" value="Français" onclick="document.pressed=this.value"/> <input type="submit" value="English" onclick="document.pressed=this.value"/> <input type="checkbox" name="remember_lang" value="yes"/>Remember my decision </form> </body> </html>
lang_check.js
var langCookie = get_cookie("lang");
if(langCookie!=""){
if(langCookie=="Français"){
document.location.href="main_fr.php";
}
else if(langCookie=="English"){
document.location.href="main_en.php";
}
}
and the functions.js (in this one I will only post the functions that you need to see ...
function check_pressed_button(){
if(document.pressed=="Français"){
if(document.langButton.remember_lang.checked){
document.write(set_cookie("lang","Français", 2100, 01, 01));
}
document.location.href="main_fr.php";
}
else if(document.pressed=="English"){
if(document.langButton.remember_lang.checked){
document.write(set_cookie("lang","English", 2100, 01, 01));
}
document.location.href="main_en.php";
}
}
My set_cookie function works fine because if I remove the "if(document.langButton.remember_lang.checked)" statement, the function saves the cookie and redirects too, but when I add the statement nothing happens...
I tried to put the checkbox in the params of the function but still doesn't work...
Thanks for the precious help, it's REALLY appreciated !

New Topic/Question
Reply



MultiQuote




|