使用XML将数字转换为星级 [英] Convert numbers into star rating using XML

查看:77
本文介绍了使用XML将数字转换为星级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很好奇如何解释这个教程,但是如何使用它将XML转换为PHP以显示星星。 此教程



我无法让星星正确填写我在输入中输入的数字,这些数字有一个新的名称。



这是我的HTML代码:

 <   div     class   = 审核率 >  
< ; pre lang < span class =code-keyword> = PHP >
< php echo ' < span class = 星级 > < span > < / span > < / span > '>
< / div >







这是我的JQuery代码:



 $( function (){
$(' 。submit-btn2')。click( function (){
$(' p')。html( ' < span class =stars>' + parseFloat($('' input [name = newrating]')。val())+ ' < / span>');
val = 数学 .round(val * 4 )/ 4 ; / * 舍入到最接近的季度* /
val = 数学 .round(val * 2 )/ 2 ; / * 舍入到最接近的一半* /
var size = 数学 .max( 0 ,(数学 .min( 5 ,val)))* 16 ;
$(' span.stars')。stars();
});
$(' 。submit-btn2')。click();
});

$ .fn.stars = function (){
return $( this )。each( function (){
$()。html($(' < span />').width( Math .max( 0 ,( Math .min( 5 parseFloat ($( this )。html()))))* 16 ));
});
}







最后,这是我的PHP表格:

 <  表格    action   =  xmlprocessad.php    方法  = < span class =code-keyword> POST    id   =  myform >  
< div class = addRev-contains >
< input 类型 = text name = newrating class = rev-input 占位符 = #/ 5 Stars > < / input > < br >
< input type = submit class = submit-btn2 >
< / div >
< / form >

解决方案

function (){


' 。submit-btn2')。click( function (){

' p')。html(' < span class =stars>' + parseFloat(


I am curious on how to interpret this same tutorial, but how can I use this to convert XML to PHP to display the stars. Tutorial Here

I cannot get the stars to fill up properly with the numbers I typed into my input that has a name of newrating.

Here is my HTML code :

 <div class="review-rate">
<pre lang="PHP">
   <php echo '<span class="stars"><span></span></span>'>
 </div>




Here is my JQuery code :

$(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));
            });
        }




Lastly, here is my PHP form:

    <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>

解决方案

(function() {


('.submit-btn2').click(function() {


('p').html('<span class="stars">'+parseFloat(


这篇关于使用XML将数字转换为星级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆