I'm having problems with a JavaScript function not firing and I can't figure out why not.
I'm opening a pop-up window which needs to pass some variables back to the opening window. I've used this code elsewhere with no problems and I've copied it and changed some of the details and now it doesn't work. It's probably going to turn out to be something so stupid but I just can't see it.

Pop-up window code:

function sendValue (employerseq,employercode,employername)
{
		var selvaluea = employerseq.value;
		var selvalueb = employercode.value;
		var selvaluec = employername.value;
		window.opener.myfunc(selvaluea,selvalueb,selvaluec);
		window.close();
}

Using alerts I can see that the correct variables have been passed into the funcion and are being assigned correctly. It doesn't seem to want to trigger the function in the opener window myfunc.

Opening Window code:

function myfunc(employerseq,employercode,employername)
{
	alert('in my function');
	window.document.getElementById('employer_seq').value = employerseq.value;
	window.document.getElementById('employer_code').value = employercode.value;
	window.document.getElementById('employer_name').value = employername.value;
}

It doesn't even trigger the first alert instruction in the function.

Can anybody see what the problem is?

I just don't get it. I left my code unchanged and used CTR+SHFT+R and now the code is working. Really frustrating.

The not working part could be from browser cache?

It does seem to be a problem with the cache. Even after clearing all the history it still wouldn't work, but CNTR+SHFT+R seems to have done the trick.

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.