🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.javascript
Article #149

Re: Cookies

#149
From: Jac.
Date: Fri, 28 Dec 2001 17:40
56 lines
2536 bytes
//--------------------------------------------------------------------------
---------------------------------

function setCookie(name, value, expire) { // ustawianie cookie
document.cookie = name + "=" + escape(value)
+ ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
}

//--------------------------------------------------------------------------
----------------------------------

function getCookie(Name) { //pobieranie zawartosci cookie
   var search = Name + "="
   if (document.cookie.length > 0) { // if there are any cookies
      offset = document.cookie.indexOf(search)
      if (offset != -1) { // if cookie exists
         offset += search.length
         // set index of beginning of value
         end = document.cookie.indexOf(";", offset)
         // set index of end of cookie value
         if (end == -1)
            end = document.cookie.length
         return unescape(document.cookie.substring(offset, end))
      }
   }
}


//--------------------------------------------------------------------------
---------------------------------

teraz tylko wystarczy, ze na onBlur zapiszesz ciacho a potem po odswiezeniu
pod value texfilda podstawisz zawartosc konkretnego ciacha.

Jac.







Użytkownik "Mariusz G." <cyclops@go2.pl> napisał w wiadomości
news:a0fmdq$f6u$1@news.tpi.pl...
> Witam
>
> Mam prosbe. Czy moglby ktos mi pomoc i napisac script oblslugujacy
Cookies.
> Chodzi mi o to ze na form'ie mam textfield i chcialbym aby za kazdym razem
> przy wejsciu na strone zapamietal wpis do tego TextField'u
> Form Name: iAccInput
> TextFiel Name: iName
>
> Pozdrawiam
>
>
Technical Details
Message-ID: <a0iar3$6fj$2@news.tpi.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!pingwin.icm.edu.pl!warszawa.rmf.pl!newsfeed.tpinternet.pl!news.tpi.pl!not-for-mail
References: <a0fmdq$f6u$1@news.tpi.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!pingwin.icm.edu.pl!warszawa.rmf.pl!newsfeed.tpinternet.pl!news.tpi.pl!not-for-mail
From: "Jac." <jlukasie@poczta.gazeta.pl>
Newsgroups: pl.comp.lang.javascript
Subject: Re: Cookies
Date: Fri, 28 Dec 2001 18:40:21 +0100
Organization: tp.internet - http://www.tpi.pl/
Lines: 60
Message-ID: <a0iar3$6fj$2@news.tpi.pl>
References: <a0fmdq$f6u$1@news.tpi.pl>
NNTP-Posting-Host: pq213.warszawa.cvx.ppp.tpnet.pl
X-Trace: news.tpi.pl 1009561252 6643 217.99.0.213 (28 Dec 2001 17:40:52 GMT)
X-Complaints-To: usenet@tpi.pl
NNTP-Posting-Date: Fri, 28 Dec 2001 17:40:52 +0000 (UTC)
X-Newsreader: Microsoft Outlook Express 5.00.2919.6700
X-MSMail-Priority: Normal
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit