/    Sign up×
Community /Pin to ProfileBookmark

Newbiequestion about Cookies!

First, excuse my bad english. Question, How will a set more values from different fields in this cookie? and how will i use document.write to display the cookie

<script language=”JavaScript”>
var theForm = document.forms[‘h_PageUI’];
</script>

<script language=”JavaScript”>
<!–
function HTMLOnLoadHandlerCallback(theForm)
{
var nameOfCookie = “COMPANY”;
alert(document.cookie.length)
if (document.cookie.length > 0){
begin = document.cookie.indexOf(nameOfCookie+”=”);
alert(“begin”+ begin)
if (begin != -1){
begin += nameOfCookie.length+1;
end = document.cookie.indexOf(“;”, begin);
if (end == -1) end = document.cookie.length;
//return unescape(document.cookie.substring(begin, end));
alert(unescape(document.cookie.substring(begin, end)))
}
}
return null;
}

function OnSubmitHandlerCallback(theForm)
{

var ExpireDate = new Date ();
// Field to set
var value = theForm.betforetag.value;

expiredays = 10;
ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
path = “/”;
document.cookie = “COMPANY” + “=” + escape(value) + ((expiredays == null) ? “” : “; expires=” + ExpireDate.toGMTString())+ “;Path=” + path;

</script>

to post a comment
JavaScript

1 Comments(s)

×

Success!

Help @MOOG 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...