<div class="review-rate"> <pre lang="PHP"> <php echo '<span class="stars"><span></span></span>'> </div>
$(function() { $('.submit-btn2').click(function() { $('p').html('<span class="stars">'+parseFloat($('input[name=newrating]').val())+'</span>'); val = Math.round(val * 4) / 4; /* To round to nearest quarter */ val = Math.round(val * 2) / 2; /* To round to nearest half */ var size = Math.max(0, (Math.min(5, val))) * 16; $('span.stars').stars(); }); $('.submit-btn2').click(); }); $.fn.stars = function() { return $(this).each(function() { $(this).html($('<span />').width(Math.max(0, (Math.min(5, parseFloat($(this).html())))) * 16)); }); }
<form action="xmlprocessad.php" method="POST" id="myform"> <div class="addRev-contain"> <input type="text" name="newrating" class="rev-input" placeholder="# / 5 Stars"></input><br> <input type="submit" class="submit-btn2"> </div> </form>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)