Click to See Complete Forum and Search --> : Can I use a wildcard in javascript?


5sisters
12-29-2002, 02:07 PM
I have this on one of my pages

document.forms[0].hiddenFieldName.value = GetCookie('PT_ToDoitem');

but 'PT_ToDoitem' is never 'PT_ToDoitem' it is 'PT_ToDoitemXX'

where XX is a number
and there can be more than one...

how can I get
document.forms[0].hiddenFieldName.value = GetCookie('PT_ToDoitem');

to read all of the 'PT_ToDoitemXX' cookies

AdamBrill
12-29-2002, 05:03 PM
Well, I don't have the code, but you should be able to run a for loop, or a do...while, to do it. You'd just have it run until the cookie equals null, then break. Try something like this:

str = "";
x = 0;

do{

str+=GetCookie('PT_ToDoitem'+x);

} while(GetCookie('PT_ToDoitem'+x)!=null)

document.forms[0].hiddenFieldName.value = str;

Something like that should work. Like I said above, though, I don't have the code, so it might need to get changed a little...

AdamBrill
12-29-2002, 05:28 PM
oops...

it should be like this:


str = "";
x = 0;

do{

str+=GetCookie('PT_ToDoitem'+x);
x++;
} while(GetCookie('PT_ToDoitem'+x)!=null)

document.forms[0].hiddenFieldName.value = str;


Sorry about that...

5sisters
12-30-2002, 05:46 AM
Thanks Adam,

I had eventually got round this using a quick & dirty fix

document.forms[0].hiddenFieldName.value = (document.cookie);


Which sent me the entire cookie!!

But I will try this way when I get a chance...

Thanks for your help...