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

Re: [jdgamble] ajax rating system

Quote Reply
Re: [jdgamble] ajax rating system In reply to
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:

Code:
<script>
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) {
updatepage(self.xmlHttpReq.responseText);
}
}
self.xmlHttpReq.send(getquerystring());
}



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;
}
</script>

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.

Code:
<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")'>
</div>
</form>

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

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

That should about do it :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
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
Subject Author Views Date
Thread ajax rating system jdgamble 44546 May 26, 2009, 1:24 PM
Post Re: [jdgamble] ajax rating system
Andy 44017 May 27, 2009, 12:34 AM
Thread Re: [jdgamble] ajax rating system
Andy 44050 May 27, 2009, 12:45 AM
Thread Re: [Andy] ajax rating system
tora 27965 Apr 8, 2018, 4:02 AM
Thread Re: [tora] ajax rating system
Andy 27905 Apr 11, 2018, 12:08 AM
Post Re: [Andy] ajax rating system
tora 27863 Apr 11, 2018, 12:46 AM
Thread Re: [Andy] ajax rating system
tora 27909 Apr 11, 2018, 12:52 PM
Thread Re: [tora] ajax rating system
Andy 27882 Apr 12, 2018, 12:59 AM
Post Re: [Andy] ajax rating system
tora 27845 Apr 12, 2018, 1:21 AM
Thread Re: [jdgamble] ajax rating system
tandat 43997 May 27, 2009, 4:53 AM
Thread Re: [tandat] ajax rating system
jdgamble 43980 May 27, 2009, 8:08 AM
Thread Re: [jdgamble] ajax rating system
Andy 43957 May 27, 2009, 8:31 AM
Thread Re: [Andy] ajax rating system
jdgamble 43966 May 27, 2009, 10:38 AM
Thread Re: [jdgamble] ajax rating system
Andy 44017 May 27, 2009, 10:44 AM
Thread Re: [Andy] ajax rating system
jdgamble 43888 May 29, 2009, 11:34 AM
Thread Re: [jdgamble] ajax rating system
Matthias70 43913 May 29, 2009, 11:44 AM
Thread Re: [Matthias70] ajax rating system
jdgamble 43883 May 29, 2009, 6:55 PM
Thread Re: [jdgamble] ajax rating system
jdgamble 43849 May 29, 2009, 10:15 PM
Thread Re: [jdgamble] ajax rating system
jdgamble 43835 May 30, 2009, 7:22 PM
Thread Re: [jdgamble] ajax rating system
Andy 43949 May 31, 2009, 1:58 AM
Thread Re: [Andy] ajax rating system
jdgamble 43761 Jun 6, 2009, 10:48 AM
Thread Re: [jdgamble] ajax rating system
Andy 43849 Jun 6, 2009, 11:05 AM
Thread Re: [Andy] ajax rating system
jdgamble 43814 Jun 6, 2009, 12:42 PM
Post Re: [jdgamble] ajax rating system
Andy 43787 Jun 6, 2009, 11:58 PM