Example with linked Rating controls
Example with single Rating control
How to Use
Linked Rating controls
Constructor Members:
var overall = new Rating("overall",
{
displayText:"Overall Rating",
afterVoteText:"Overall Rating",
starsCount:5,
value:3,
emptyImageUrl:"Images/star_empty.gif",
hoverImageUrl:"Images/star_hover.gif",
votedImageUrl :"Images/star_voted.gif",
afterYouVotedImageUrl:"Images/star_f.gif",
votedHalfImageUrl :"Images/star_voted_half.gif",
votedHalfImageUrl :"Images/star_voted_half.gif",
afterYouVotedHalfImageUrl:"Images/star_h.gif",
isEnabled:false } );
new Rating("ratings",
{
urlToSend:'http://'+document.domain+'/JS/Ratings/getVote.php',
overallRating:overall,
displayText:"Your Rating",
afterVoteText:"Your Rating",
onSendText:" Sending your Vote...",
starsCount:5,
hints: [ 'Bad','Normal' , 'Good','Great' ,'Super!'],
value:0,
id:13124,
emptyImageUrl:"Images/star_empty.gif",
hoverImageUrl:"Images/star_hover.gif",
votedImageUrl :"Images/star_voted.gif",
afterYouVotedImageUrl:"Images/star_f.gif",
votedHalfImageUrl :"Images/star_voted_half.gif",
votedHalfImageUrl :"Images/star_voted_half.gif",
afterYouVotedHalfImageUrl:"Images/star_h.gif",
isEnabled:true
} );
Where
var overall - overall rating, wich used to display Averadge voting information
urlToSend - as example http://'+document.domain+'/JS/Ratings/getVote.php', document.domain - in case user type in browser ajaxline.com insted of www.ajaxline.com... so httprequest will be blocked by browser security
"overall" and "ratings" - id's of spans.
id - sends in GET as "id" through Ajax
value - sends in GET as "value"
Single Rating control
new Rating("tick",
urlToSend:'http://'+document.domain+'/JS/Ratings/getVote.php',
displayText:"Your Rating",
afterVoteText:"Current Rating",
onSendText:" Sending your Vote...",
starsCount:5,
hints: [ 'Bad','Normal' , 'Good','Great' ,'Super!'],
value:0,
id:13123,
emptyImageUrl:"Images/empty_tick.gif",
hoverImageUrl:"Images/green_hover.gif",
votedImageUrl :"Images/voted_tick.gif",
afterYouVotedImageUrl:"Images/voted_tick.gif",
isEnabled:true }
);
Server Side
PHP
<?php if ($_GET['id']==13123){ print '4';} else print '4.5'; ?>
You print value wich you want to show in your Rating control(it can be Average value of voutings)
ASP.NET
protected void Page_Load(object sender, EventArgs e)
{
string value = "";
string id = "";
if (Request["value"] != null)
value = this.Request["value"].ToString();
if (Request["id"] != null) value = this.Request["id"].ToString();
// then you process value and respond average value(by example 3)
this.Response.Clear();
this.Response.Write(3);
Response.End();
}
Igor Kononuchenko(Kigorw) www.ajaxline.com 2006