Home : Products : Gossamer Links : Development, Plugins and Globals :

Products: Gossamer Links: Development, Plugins and Globals: Re: [jdgamble] ajax rating system: Edit Log

Here is the list of edits for this post
Re: [jdgamble] ajax rating system
Ok, took a little while to piece together again - but here you go (I'm sure this will be very useful to other people too =))

In detailed.html, add this into the header:

function xmlhttpPost(strURL) {

var xmlHttpReq = false;
var self = this;

// Mozilla/Safari
if (window.XMLHttpRequest) {
self.xmlHttpReq = new XMLHttpRequest();

// IE
else if (window.ActiveXObject) {
self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");

self.xmlHttpReq.open('POST', strURL, true);
self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
self.xmlHttpReq.onreadystatechange = function() {
if (self.xmlHttpReq.readyState == 4) {

function getquerystring() {

var form = document.forms['rateform'];
var ID = form.ID.value;
var rate;
for (var i = 0; i < form.rate.length; i++) {
if(form.rate[i].checked){ rate = form.rate[i].value; }

var qstr = 'ID=' + escape(ID) + ';rate=' +escape(rate);
return qstr;


function updatepage(str){
document.getElementById("result").innerHTML = str;

Then, put this EXACT code where you want the rate box to show. The <div id="result"> is very important, as thats where the code is put for showing a succesful update.

<form name="rateform"><strong>Rate the site <%Title%>:</strong>
<div id="result">
<input type="hidden" name="ID" value="854" />
<input type="radio" id="rate1" name="rate" value="1">1
<input type="radio" id="rate2" name="rate" value="2">2
<input type="radio" id="rate3" name="rate" value="3">3
<input type="radio" id="rate4" name="rate" value="4">4
<input type="radio" id="rate5" name="rate" value="5">5
<input type="radio" id="rate6" name="rate" value="6">6
<input type="radio" id="rate7" name="rate" value="7">7
<input type="radio" id="rate8" name="rate" value="8">8
<input type="radio" id="rate9" name="rate" value="9">9
<input type="radio" id="rate10" name="rate" value="10">10
<input value="Go" type="button" onclick='JavaScript:xmlhttpPost("<%config.db_cgi_url%>/rate.cgi")'>

Then, in rate_success.html, change the whole page to just have the text you wanna show - for example:

Thanks for rating <%Title%>. It wil show up in the next update.

That should about do it :)


Andy (mod)
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!

Last edited by:

Andy: May 29, 2009, 11:43 AM

Edit Log: