Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: set cookie after click on input
Forum PHP.pl > Forum > Przedszkole
Guest
jak klikajac na
  1. <input type="button">
utworzyć cookie o nazwie wyszukiwarka i zawartości wpisanego slowa to wczesniejszego pola
  1. <input type="text">
Prph
1. set cookie after click on input - co to za nazwa topica?
2. Ja nie bardzo rozumiem. To ma sie dziac po stronie przegladarki, czy serwera?
3. Po co Ci to?

Pozdrawiam, Adrian.
Guest
1.2.3: po to aby jesli wyszukiwarka ktora stworzylem, po przeładowaniu lub wybraniu opcji WSTECZ w przeglądarce pamietala wpisane slowo i wyswietlala w polu input
mike
Googl.pl :: search :: javascript + setcookie
Tak trudno było?
Rozwiązań od groma.
Guest
znalazlem cos takiego
  1. <script type="text/javascript" language="JavaScript">
  2. <!--
  3. function SetCookie(cookieName,cookieValue,nDays) {
  4. var today = new Date();
  5. var expire = new Date();
  6. if (nDays==null || nDays==0) nDays=1;
  7. expire.setTime(today.getTime() + 3600000*24*nDays);
  8. document.cookie = cookieName+"="+escape(cookieValue)+";expires="+expire.toGMTString();
  9. }
  10. //-->
  11. <form name="setCookie">
  12. <input type="hidden" name="wyszukiwarka" value="wyszukiwarka">
  13. <input type="hidden" name="czas" value="5">
  14. <input size="25" type="text" name="findthis">
  15. <input type="submit" value="OK" onClick="SetCookie(this.form.wyszukiwarka.value,this.form.findthis.value,this.form.czas.value);">
  16. </form>

ale jak po przeladowaniu strony wyswietlic ostatnio zapisane cookie w polu input?
erix
to tez mozna znalezc w Google'ach, ale przypomnialo mi sie gdzie na dysku lezalo cos takiego:
Kod
//  Cookie Functions - Second Helping  (21-Jan-96)
//  Written by:  Bill Dortch, hIdaho Design <bdortch@netw.com>
//  The following functions are released to the public domain.

function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;
  }
  return null;
}

function SetCookie (name, value) {
  var argv = SetCookie.arguments;
  var argc = SetCookie.arguments.length;
  var expires = (argc > 2) ? argv[2] : null;
  var path = (argc > 3) ? argv[3] : null;
  var domain = (argc > 4) ? argv[4] : null;
  var secure = (argc > 4) ? argv[5] : false;
  document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain));
}

function DeleteCookie(name){
exp=new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie ("name");
document.cookie = name + "=" + cval +"; expires=" + exp.toGMTString();
}
seaquest
Starczy
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.