Click to See Complete Forum and Search --> : Cookie


fark
10-08-2003, 09:04 AM
I have this stored in my cookie
134 Hill St
when I use this to print it out
Response.Write Request.Cookies("UserInput")(Street)
it prints out
134HillSt

What is the appropriate way to handle spaces in a cookie?
Thanks

fark
10-08-2003, 10:34 AM
I forgot that I write to the cookie in javascript. I used a test file to figure out how Request.Cookies formats it's cookie but I didn't include an input with a space. Request.Cookies puts a + in place of the spaces. Now I just have to figure out how to get this function to look for a space in document.frm1.elements[i].name and replace it with a +. I'm not very good at javascript any ideas? How do I look at each character in the string? Thanks, Sorry I'm still learning.

function SaveInCookie() {
strRecord = "";

strRecord="Length=" + document.frm1.elements.length + "&";
for(i = 0; i < document.frm1.elements.length; i++) {
strRecord = strRecord + 'Input' + i + '=' + document.frm1.elements[i].name + '&' + document.frm1.elements[i].name + '=' + document.frm1.elements[i].value + '&';
}
arrRecords[recCount] = strRecord;

document.cookie = "UserInput="+arrRecords+";expires=" + expireDate.toGMTString();
window.location.href="preview3.asp";
}