Grey Matter Forums
« Javascript to Save a Commenter's Info »

Welcome Guest. Please Login or Register.
May 21, 2013, 9:24am



Greymatter: Free Personal Blogging Software

About Greymatter (including System Requirements)

Greymatter on FreshMeat

Download current version from:

News: Greymatter 1.8.2 is released! Read the announcement.

Got a minute? We want to know what's your preferred site navigation?

Please read the security announcement regarding author passwords.

Next Greymatter release will be 1.8.3


Grey Matter Forums :: Support :: Cookbook :: Javascript to Save a Commenter's Info
   [Search This Thread] [Share Topic] [Print]
 AuthorTopic: Javascript to Save a Commenter's Info (Read 4,572 times)
coldstone
Global Moderator
*****
member is offline

[avatar]


[homepage]

Joined: Aug 2006
Posts: 816
Karma: 18
 Javascript to Save a Commenter's Info
« Thread Started on Apr 4, 2007, 10:42pm »

Problem: I would like a commenter's name, email, and homepage to be remembered after they comment and to automatically appear in the comment form fields.

Solution: GreyMatter comes with the javascript to do this, however, it isn't "hooked up" so to speak. A little template modifications and you are good to go.

First make sure that you have the cookie code variable ({{cookiescode}}) in your Entry Page Template templates (which the standard templates that ship with GM do).

Add these lines to your "{{entrycommentsform}} Posting Form" template:
Code:
<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">
<!--//
document.newcomment.newcommentauthor.value = getCookie("gmcmtauth");
document.newcomment.newcommentemail.value = getCookie("gmcmtmail");
document.newcomment.newcommenthomepage.value = getCookie("gmcmthome");
document.newcomment.newcommentauthor.focus();
//-->
</SCRIPT>
<input name="bakecookie" type="checkbox" />Save Info?<br />


This goes nicely just in front of the 'Reset' button.

Lastly, modify your submit button to call the 'setGMcookies' javascript function. In your "{{entrycommentsform}} Posting Form" template change:
Code:
<input type="submit" value="Submit" class="button" />

to:
Code:
<input type="submit" value="Submit" class="button" onClick="javascript:setGMcookies()" />


Discussion: As features have been added, not all of them have been documented, particularly with the powerful template system that GreyMatter has. This recipe doesn't require any code modification, yet it is able to significantly enhance the user experience. If every template configuration were absorbed into the code, GreyMatter would quickly become unusable.

Note: If you have trouble getting the javascript to work, most browsers have an 'Error Console' that may give some feedback. Also, Firebug is an amazing Firefox plugin that can be very helpful.
« Last Edit: Apr 4, 2007, 11:04pm by coldstone »Link to Post - Back to Top  IP: Logged
iamgundam
New Member
*
member is offline





Joined: May 2008
Posts: 1
Karma: 0
 Re: Javascript to Save a Commenter's Info
« Reply #1 on May 18, 2008, 4:44am »

thank Q very much
Link to Post - Back to Top  IP: Logged
xiaojunznz2
New Member
*
member is offline





Joined: May 2013
Gender: Male
Posts: 3
Karma: 0
 Re: Javascript to Save a Commenter's Info
« Reply #2 Today at 5:10am »

You can surf the Internet access to relevant data and information, and discuss with friends, maybe can help you, wish you good luck.

__________________
I have a dream,it is a fantasy forever.
buy diablo 3 Gold|RS Gold|Diablo 3 Gold|WOW Gold
Link to Post - Back to Top  IP: Logged
   [Search This Thread] [Share Topic] [Print]

Click Here To Make This Board Ad-Free


This Board Hosted For FREE By ProBoards
Get Your Own Free Message Boards & Free Forums!
Terms of Service | Privacy Policy | Notice | FTC Disclosure | Report Abuse | Mobile