How to set value of hidden input after choosing rating?

Jul 14, 2011 at 7:31 AM

This must be something simple to do but I can't figure it out.

After the user selects a rating how do I set that to the value of a hidden input? How do I make sure the hidden input value gets updated if the user changed their rating after?

Thanks!!!

Jul 14, 2011 at 7:36 AM

This is the code I am trying and it is not working:

<div class="rateit" id="rateit9"></div>                              

<script type="text/javascript">
$(document).ready(function() {
    $("#rateit9").bind('rated', function (event, value) {
    document.getElementById(review_rating).value=$('#rateit9').rateit('value');
    });
});
</script>
                   
<input type="hidden" name="review_rating" id="review_rating" value=""/>  

Jul 14, 2011 at 7:39 AM

Actually I got it working, I was just missing quotes around the ID name:

 

document.getElementById("review_rating").value

Coordinator
Jul 14, 2011 at 1:09 PM

Actually RateIt supplies the functionality out of the box:

<input type="hidden" id="review_rating">
<div class="rateit" data-rateit-backingfld="#review_rating" id="rateit9"></div>
No extra code needed.
Aug 15, 2012 at 5:15 PM

Hey Guys.

How can I implement this function in a while?

The function showed just returns one value, I need to get all the mysql values and show the rate.

Any suggestion?

 

Tks

Coordinator
Aug 19, 2012 at 1:03 PM

Could you be a bit more specific?

 

It does sound like you could use the backingfield property:

 

<input type="range" min="0" max="7" value="0" step="0.5" id="backing2">
<div class="rateit" data-rateit-backingfld="#backing2"></div>