I am working on a java project and I need to add cookie in the browser to register a record of points of the person and turns it into a variable "a".
I have everything working ... just missing it!
the project is a play test of reflex and just missing that part.
I put the most important (the start and the function that I want to change, respectively)
the function is enabled by a button
the variable "a" is defined as 10000000
ps: the project is in Portuguese because I am Brazilian!

var startTime=new Date();
var endTime=new Date();
var startPressed=false;
var bgChangeStarted=false;
var maxWait=20;
var timerID;
var a=10000000
var colors=new Array("red")


(...)

function stopTest()
{
	if(bgChangeStarted)
	{
		endTime=new Date();
		var responseTime=(endTime.getTime()-startTime.getTime())/1000;
		var responseTime2=(endTime.getTime()-startTime.getTime());
		if (a > responseTime2){
		a=responseTime2
		c="#00FF00"
		}
		if (a < responseTime2){
		a=a
		c="red"
	    }
		
                if (document.all)
		document.all.reflex.style.backgroundColor="green";
                else if (document.getElementById)
		document.getElementById("reflex").style.backgroundColor="green";
                else if (document.layers)
                document.reflexns.document.reflexns_sub.document.bgColor="green";      
		//alert("Tempo de resposta: " +responseTime2 +" ms" + "\n" + remark(responseTime));
		document.getElementById("resultado").innerHTML=('<font color="'+c+'" size="7">'+responseTime2+' ms</font><br><font color="#00FF00">'+ remark(responseTime)+'   ------   Melhor tempo: </font><font color="blue">'+a+" ms<br>Best do Windsdon: 176 ms</font>");
		startPressed=false;
		bgChangeStarted=false;
	}else{

This will do it...
I bring up some additional lines in your code...

/* A D D I T I O N A L
   B L O C K S ~

   Do not try to alter anything
   beyond this block or this
   code will break */

var expiry = new Date();
expiry.setTime(expiry.getTime() + ( 1000 * 60 * 60 * 24 * 30 ));

var score = { save : function(scores,value,expires) {
return document.cookie = scores + '=' + escape( value ) + '; path=/' + (( expires == null ) ? '' : '; expires=' +  expires.toGMTString());
 }, show : function(scores) {
   var lastScore = scores + '=';
   var yScore = document.cookie.indexOf(lastScore);
      if (yScore == -1) { return null; }
   var total = document.cookie.indexOf(';', yScore + lastScore.length);
      if (total == -1) { total = document.cookie.length; 
return unescape(document.cookie.substring(yScore + lastScore.length, total)); 
    }
  } 
}
/* A D D I T I O N A L 
   B L O C K S
   E N D E D */


var startTime=new Date(); var endTime=new Date(); var startPressed=false; var bgChangeStarted=false; var maxWait=20; var timerID; var a=10000000 var colors=new Array("red") (...) function stopTest() { if(bgChangeStarted) { 

// New line(1)...
score.save('theirScore',a,expiry);

endTime=new Date(); var responseTime=(endTime.getTime()-startTime.getTime())/1000; var responseTime2=(endTime.getTime()-startTime.getTime()); if (a > responseTime2){ a=responseTime2 c="#00FF00" } if (a < responseTime2){ a=a c="red" }    if (document.all) document.all.reflex.style.backgroundColor="green";    else if (document.getElementById) document.getElementById ("reflex").style.backgroundColor="green";    else if (document.layers)    document.reflexns.document.reflexns_sub.document.bgColor="green";  //alert("Tempo de resposta: " +responseTime2 +" ms" + "\n" +remark(responseTime)); document.getElementById ("resultado").innerHTML=('<font color="'+c+'" size="7">'+responseTime2+' ms</font><br><font color="#00FF00">'+ remark(responseTime)+' ------ Melhor tempo: </font><font color="blue">Getting the score with cookie '+score.show('theirScore')+" ms<br>Best do Windsdon: 176 ms</font>"); startPressed=false; bgChangeStarted=false; }else{
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.