Set readonly attribute at server side

Jul 30, 2012 at 2:00 AM
Edited Jul 30, 2012 at 2:10 AM

Hi, first of all great plugin! It saved me a lot of work. Have a bit trouble at start trying to get it working with AJAX but got it working.

Now I'm building a movie website where users can register, after that users can post comments, rate movies, etc

Now how would I set the readonly attribute via PHP server side? Because I need to check if the user has already rated a movie (update/reset rate will be for the near future :) )

Thanks in advance.


Though of changing style attribute display to none (<div class="rateit-reset" style="display: none;"></div>) because you do this in your example page.

Jul 30, 2012 at 10:20 AM
Edited Jul 30, 2012 at 10:20 AM


I don't really know PHP, but since we are talking about a client side technology, the resides on the client side.

I guess that you are looping in php over a recordset with movies, and next to each movie want to place a rateit control.
Currently I guess you are simply writing:
<div class="rateit" />

You should replace this with something like this (I don't know PHP , so I'm not sure if this is the correct syntax):

<div class="rateit" <?php echo ($hasvoted == 'true' ? 'data-rateit-readonly="true" data-rateit-value="' . $ratevalue .'"') ?> />

Jul 30, 2012 at 12:08 PM

Just what I needed thanks!

Jul 30, 2012 at 3:17 PM


you could also add the data-rateit-ispreset="true" attribute. This gives the star an orange color (if you use the default stars), and gives the user an indication that he already voted on that one.