This is my code:
var j = 0;
var c = 0;
var riepvet = new Array();
function controllo() {
if ((src1 == "") || (src1 == "undefined")) {
alert("Selezionare un'immagine.");
}
else if(j==0) {
riepvet[c] = src1;
c++;
for (var k = 0; k < c; k++) {
alert(riepvet[k]);
}
location.href = "schienale.html";
j++;
}
else if (j==1){
riepvet[c] = src1;
c++;
for (k = 0; k < c; k++) {
alert(riepvet[k]);
}
location.href = "riep.html";
j++;
}
}
What I need, is make the numeric variables j
and c
available through all the pages of my program. Is this possible using cookies (since they aren't string but numbers)?
I've already tried to use eval()
but it seems not to work.
Any suggestions?
Edit:
Cookies.set('j', 0);
var j = parseInt(Cookies.get('j'));
Cookies.set('imuno');
var imuno = Cookies.get('imuno');
Cookies.set('imdue');
var imdue = Cookies.get('imdue');
function controllo() {
if ((src1 == "") || (src1 == "undefined")) {
alert("Selezionare un'immagine.");
}
else if (j == 0) {
imuno = src1;
Cookies.set('imuno', src1);
alert(imuno);
location.href = "schienale.html";
j++;
Cookies.set('j', 1);
}
else if (j == 1) {
imdue = src1;
Cookies.set('imdue', src1);
alert(imuno,imdue);
location.href = "riep.html";
j++;
Cookies.set('j', 2);
}
}
When i retrieve the function Controllo()
the variable j
does not mantain the value.