Ciao da un incapace, vengo subito al dunque![]()
avete presente un piccolo form per l'inserimento dei commenti in un blog? C'è un campo autore, uno e-mail, uno homepage e la textarea per scrivere il commento
ora, il mio problema riguarda i cookies, che non vengono memorizzati. Ho usato questo script (il problema lo spiego alla fine):
Nel body invece ho messo questocodice:<script> // Copyright (c) 1996-1997 Athenia Associates. // http://www.webreference.com/js/ // License is granted if and only if this entire // copyright notice is included. By Tomer Shiran. function setCookie (name, value, expires, path, domain, secure) { var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : ""); document.cookie = curCookie; } function getCookie (name) { var prefix = name + '='; var c = document.cookie; var nullstring = ''; var cookieStartIndex = c.indexOf(prefix); if (cookieStartIndex == -1) return nullstring; var cookieEndIndex = c.indexOf(";", cookieStartIndex + prefix.length); if (cookieEndIndex == -1) cookieEndIndex = c.length; return unescape(c.substring(cookieStartIndex + prefix.length, cookieEndIndex)); } function deleteCookie (name, path, domain) { if (getCookie(name)) document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT"; } function fixDate (date) { var base = new Date(0); var skew = base.getTime(); if (skew > 0) date.setTime(date.getTime() - skew); } function rememberMe (f) { var now = new Date(); fixDate(now); now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000); setCookie('mtcmtauth', f.author.value, now, '', HOST, ''); setCookie('mtcmtmail', f.email.value, now, '', HOST, ''); setCookie('mtcmthome', f.url.value, now, '', HOST, ''); } function forgetMe (f) { deleteCookie('mtcmtmail', '', HOST); deleteCookie('mtcmthome', '', HOST); deleteCookie('mtcmtauth', '', HOST); f.email.value = ''; f.author.value = ''; f.url.value = ''; } //--> </script>
e poi c'è questa cosa che non so a cosa serva (e se me lo spiegate mi fate un favore)codice:<form method="post" action="<$MTCGIPath$><$MTCommentScript$>" name="comments_form" onsubmit="if (this.bakecookie[0].checked) rememberMe(this)"> <input type="hidden" name="entry_id" value="<$MTEntryID$>" /> <label for="author">Nome:</label> <input tabindex="1" id="author" name="author" class="formcommenti" /> <label for="email">Email:</label> <input tabindex="2" id="email" name="email" class="formcommenti" /> <label for="url">URL:</label> <input tabindex="3" id="url" name="url" class="formcommenti" /> Memorizza i dati inseriti? <input type="radio" id="bakecookie" name="bakecookie" /><label for="bakecookie">Sì</label><input type="radio" id="forget" name="bakecookie" onclick="forgetMe(this.form)" value="Forget Info" /><label for="forget">No</label> <label for="text">Commenti:</label> <textarea tabindex="4" id="text" name="text" rows="10" cols="50" class="formcommenti"></textarea> <input type="button" onclick="window.close()" value=" Cancella " class="formcommenti" /> <input style="font-weight: bold;" type="submit" name="post" value=" Post " class="formcommenti" /> </form>
ora io vorreicodice:<script type="text/javascript" language="javascript"> <!-- document.comments_form.email.value = getCookie("mtcmtmail"); document.comments_form.author.value = getCookie("mtcmtauth"); document.comments_form.url.value = getCookie("mtcmthome"); if (getCookie("mtcmtauth")) { document.comments_form.bakecookie[0].checked = true; } else { document.comments_form.bakecookie[1].checked = true; } //--> </script>
) che i cookies funzionassero: c'è una casella "ricorda cookies", ma qualcosa non va, perchè non li ricorda
) che una volta postato il messaggio si venisse reinviati alla stessa pagina: come si fa?
Grazie![]()

Rispondi quotando

