One Recommend Form To Recommend Many Individual Pages
Master Recommend was the first Perl CGI program we offered to the Internet webmaster community. This was in year 1998.
There have been improvements made to the program. And there is now a commercial, pro version. Master Recommend Pro V4 has a control panel with a form generator and lots of ways to control the program.
The URLs to the two programs are /a/25t/pl.pl?mr and /a/25t/pl.pl?mrp
One of the most frequent questions we receive about these programs is how to use one form page to recommend many individual web pages. Because the title and URL of the web page being recommended are specified in hidden form fields, the information about the individual web pages must somehow be inserted.
That's what this article is about.
Although the instructions are for forms using Master Recommend and Master Recommend Pro V4, the method may be adapted for use with forms using other "recommend this site" programs and even with other types of forms.
It's done with JavaScript, or a JavaScript/CGI combination, depending on whether or not you wish to customize only the hidden fields or also the text surrounding the form.
How it Works
Two web pages are involved; the web page being recommended and the web page with the recommend form.
The web page being recommended has a "recommend me" link. It also has JavaScript that changes the "recommend me" link. Once changed, the link contains information the recommend form will need.
The web page with the recommend form has JavaScript that accepts the information from the "recommend me" link when the link is clicked. The JavaScript uses the information to change the values of two hidden fields in the form so they contain the title and the URL of the web page being recommended.
The Two Hidden Fields
The two hidden fields where the JavaScript will insert information are slightly different for Master Recommend than they are for Master Recommend Pro V4.
Both forms' hidden fields are where the recommended web page name and the recommended web page URL are specified. (The forms have other hidden fields, but it's only those two we're concerned with here.)
The two hidden fields for Master Recommend are name="sitename" and name="siteurl"
The two hidden fields for Master Recommend Pro V4 are name="sitename" and name="siteURL"
Notice that the hidden field for the web page name is identical in both forms. And the hidden field for the web page URL is different only in letter case. But form fields are case sensitive, which means the two would be seen as altogether different by the recommend form processing program.
The Two Methods
The purely JavaScript method modifies the two hidden fields of the recommend form. It's used if only the hidden fields need to be changed, when all form and surrounding text can remain as it is.
The JavaScript/CGI combination method can also modify text in or around the recommend form to personalize it for the web page being recommended. This is used when, in addition to the two hidden fields that need to be changed, form text or text surrounding the form needs to be customized to reflect the recommended page's title and/or URL.
A ZIP file with examples and instructions to implement both methods is at /a/25t/pl.pl?art255
Have fun with it. And profit.
Unsolicited personal recommendations are probably the best advertising in the world.
Question:
Did you find this article interesting and understandable? How can it be improved?
Your response is anonymous.
When done typing, click anywhere outside the box. [more info]
Will Bontrager
©2004 Bontrager Connection, LLC
Please note:
Articles on this website are presented "as is". However -
If you have a question about a CGI script, HTML, CSS, PHP, or JavaScript
Ask one of our Experts and you'll have your answer!
Click here for details.