Meetings every second Tuesday
Javascript/Cookie Question
I'm trying to store some cookies on a number pages on my PHP project.
It's pretty straight forward except when it comes to storing the cookie
data. I have quite a few pages, each with many form propertie
that need to stored. I don't want to write all that code and remember
to go back and change it when the page changes, so I'm looking for
a way to loop through my form properties and store them in the cookie.
I can do the loop part, but it's the assigning the property value
to the cookie that has me stump. Here is the code I've got so far.
What I'm look for is a way to name the target name. I can set
the value not the target name with object cookie. Hope this
makes sense
Thanks
K
function writecookie() {
for(var elm in document.form) {
confirm(doform[elm].name);
// I want something like this, but it doesn't work;
cookie[document.form[elm].name] = document.form[elm].value};
}
//This works, but there way too many of them to handle by hand.
cookie.emp_lastname=document.form.emp_lastname.value;
cookie.emp_middlename=document.form.emp_lastname.value
cookie.emp_firstname=document.form.emp_firstname.value;
// dozens more!!!
cookie.store(1);
}




Recent comments
1 week 2 days ago
1 week 2 days ago
1 week 2 days ago
1 week 3 days ago
1 week 3 days ago
4 weeks 6 days ago
7 weeks 10 hours ago
8 weeks 5 days ago
9 weeks 6 days ago
9 weeks 6 days ago