Debt Consolidation - Property in Dubai - Deaf Topics - Deaf Topics - Property in Dubai

PDA

View Full Version : Create a cookie from form variable.


andykzzzzzz
Dec 4th 2006, 12:57 pm
I have a form that corrects a quiz and assigns the number correct to a variable. This is the code:

function scoretest(form) {
score=0
var page=null
if (form.question1.value=="1") { score=score+1; }
if (form.question2.value=="1") { score=score+1; }
if (form.question3.value=="1") { score=score+1; }
if (form.question4.value=="1") { score=score+1; }
if (form.question5.value=="1") { score=score+1; }
if (form.question6.value=="1") { score=score+1; }
if (form.question7.value=="1") { score=score+1; }
if (form.question8.value=="1") { score=score+1; }
if (form.question9.value=="1") { score=score+1; }
if (form.question10.value=="1") { score=score+1; }

form.per.value = (score / 10)*100
form.score.value = (score);

document.cookie=score;


THIS WORKS. It scores the quiz and creates a cookie. BUT it doesn't name the cookie. It just sends the cookie value. I need to name the cookie so that I can retrieve it later.

Any help or ideas would be appreciated.

lbalance
Dec 4th 2006, 2:44 pm
document.cookie =
'cookiename=value; expires=Mon, 4 Dec 2006 12:00:00 UTC; path=/'



fill in the cookiename with whatever you want to call it.
set the value and put in an expire date too.