Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using cookie to retreive form values works in ie not in nn6

Status
Not open for further replies.

niblet

Programmer
Aug 7, 2001
30
US
Happy New Year ...

I am using the following code to remember the values of forms. This works in IE, when I come back to the form all the values are set to the last entry value, that is what I want.

I know the cookies are being set in NN6 as I can see the values by looking in the cookie manager, however, in NN6 the form values are not reset when the user comes back to the page as they are in IE.

This function is called onLoad in the body tag of the HTML doc. ....

any thoughts ???

much appreciated ....


Code:
function initForm(currentForm)
{
	with(currentForm)
	{
		formElements = elements.length
		for(var i=0; i < formElements; i++)
		{
			var name = elements[i].name;
			value = getCookie(name);
			if(value != null)
			{
				elements[i].value = value;
			}
		}//for
	}//with
}//initForm
 
I figured this out and thought I would say what I found.

I had the onLoad=initForm(test) ... where test is the name of the form in the document. This worked fine in IE
I changed it to onLoad=initForm(document.test)and all the form fields that were stored in the cookie were filled in for both nestscape and ie. So it just couldn't find the form, it was never a cookie problem. I'm learnin'

hope this helps someone else in the future....

I was testing in Netscape 6.0.

niblet
 
as another tip, you may find that this still errors when used in certain NS versions when called with onload - I've found that this is cos onload in NS doesn't really MEAN on load, hence the document (and therefore forms) don't fully exist and the init call may fail!! I tend to add the call at the end of the page itself - messy, I know, but that's clientside coding for ya!

regards,

CJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top