/    Sign up×
Community /Pin to ProfileBookmark

cookies/dropdown menu/function/ trouble with cookies

I have made several attempts to save a cookie with the dropdown menu form.
I have taken code directly from the HTML Goodies, the only thing I changed was the form.
Is there a special way to save cookies with the dropdown menu form?

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 3.2//EN”>
<html>
<head>
<!– javascript functions in here –>
<SCRIPT LANGUAGE=”JavaScript”>
cookie_name = “dataCookie”;
var YouEntered;
function putCookie() {
if(document.cookie != document.cookie)
{index = document.cookie.indexOf(cookie_name);}
else
{ index = -1;}if (index == -1){YouEntered=document.cf.cfd.value;document.cookie=cookie_name+”=”+YouEntered+”; expires=Monday, 04-Apr-2010 05:00:00 GMT”;}}
</SCRIPT>
</head>
<body>
<FORM NAME=”cf”>

<!— (original code) Enter A Word: <INPUT TYPE=”text” NAME=”cfd” size=”20″> —>
<!— begin new form here —>
<SELECT NAME=”cfd” SIZE=”1″><OPTION SELECTED>Blue<OPTION>Red<OPTION>Yellow<OPTION>Green<OPTION>Black<OPTION>Orange<OPTION>Purple</SELECT>
<!— end new form —>
<INPUT TYPE=”button” Value=”Set to Cookie”
onClick=”putCookie()”>
</FORM>
</body>
</html>

This is only a cookie test code. I eventually will need to save about eight cookies from eight dropdown menus.

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@Khalid_AliAug 04.2004 — ....

[url=http://www.webapplikations.com/pages/html_js/document/SimpleLoginCookieScript.html]This is prety simple and straight forward[/url]

cookie script..I hope it will help you understand the concept a bit better.
×

Success!

Help @anothen spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.22,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...