Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/234.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php ui滑块上的值_Php_Javascript_Html_Jquery Ui_Slider - Fatal编程技术网

Php ui滑块上的值

Php ui滑块上的值,php,javascript,html,jquery-ui,slider,Php,Javascript,Html,Jquery Ui,Slider,我有一个滑块的代码,结构显示正确,但当我移动滑块时,不会在“金额”输入框内显示答案的值,显示为“未定义”,我不知道为什么,因为当您检查时,可以看到div滑块在标记名中有一个值。我也尝试过使用html标记“value”,但效果不太好。我能做什么 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

我有一个滑块的代码,结构显示正确,但当我移动滑块时,不会在“金额”输入框内显示答案的值,显示为“未定义”,我不知道为什么,因为当您检查时,可以看到div滑块在标记名中有一个值。我也尝试过使用html标记“value”,但效果不太好。我能做什么

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <title>  Questionnaire </title>
    <meta name="Description" content="Questionnaire on business model" />
    <script src="jquery-1.8.3.js" type="text/javascript"></script>
    <script src="jquery.validationEngine-en.js" type="text/javascript" charset="utf-8"></script>
    <script src="jquery.validationEngine.js" type="text/javascript" charset="utf-8"></script>
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
    <script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>    
    <script src="jquery-ui-1.9.2.js"></script>
    <script src="factaris.js"></script> 
    <link rel="stylesheet" href="STYLE.css" type="text/css" media="screen" />
    <script>
    jQuery(document).ready(function(){

        ///SLIDER !!!!!!!!!!!!!!!!!!!!!!!!!!!

        $( "#slider" ).slider({ 
        slide: function( event, ui ) {
            //$( "#amount" ).val( "$" + ui.value );  // show range 0-100 without ini values !!!!!
            // $( "#amount" ).val( "$" + this.value  ); //show undefined
            //   $( "#amount" ).val( "$" + 8); // show 8 all time
            $( "#amount" ).val( "$" + ui.name );    
        }
        });     
    });
    </script>
</head>
<body>
<div id="sizer">
    <form id= "formID"  name="formID" class="formular"   method="post" action= "<?= $url = "QUESTIONAREFINISHING.php"; ?>" accept-charset="utf-8">
    <div id="questionare" >
    <!--SLIDER-->   

    <?php if($row_questionset['Constructor']=="Slider"){?>
    <div>
        <label class="desc" value= "<?php $row_questionset['QuestionIDFKPK'];?>">
        <?php echo $row_questionset['QuestionValue']; ?>
        </label>
    </div>                                                          
    <?php while ($row_Answer=mysql_fetch_array($AnswersValue)){ ?>  
    <p>
        <label for="amount"><?php echo $row_questionset['QuestionValue']; ?></label>
        <input type="text" id="amount" name="amount"  />
    </p>

    <div id="slider" name="<?php echo $row_Answer['AnswerValue']; ?>" ></div>

    <?php } // End while loop ?>
    <?php } //End slider row ?> 
    <!--/SLIDER-->  
    </div>   
</form>
</div>   
</body>    
</html>

问卷调查
jQuery(文档).ready(函数(){
///滑块!!!!!!!!!!!!!!!!!!!!!!!!!!!
$(“#滑块”)。滑块({
幻灯片:功能(事件、用户界面){
//$(“#amount”).val($”+ui.value);//不带ini值的显示范围0-100!!!!!
//$(“#amount”).val($”+this.value);//显示未定义
//$(“#amount”).val($”+8);//始终显示8
$(“#金额”).val($”+ui.name);
}
});     
});

要读取jQuery UI滑块的值,您需要对相关元素调用Slider方法,并将“value”作为参数,如下所示:

$( "#slider" ).slider( "value" );

使用“值滑块”参数,如果要在更改滑块或/和在幻灯片上读取值,请使用滑块的事件方法:

function outputValue(sliderDom) {
    alert($(sliderDom).slider('value'));
};

$( "#slider" ).slider({
    //... your init
    slide: function(){
        outputValue(this);
    },
    change: function(){
        outputValue(this);
    }
});
编辑

要解决您的价值问题,请尝试以下方法

$('#slider').slider({
    //..
    min: 0,
    max: 100000 //or more
});

如果希望mto设置初始值,则需要在调用
slider
方法(使用JS-而不是HTML)时进行设置


请删除所有的空行好吗?我试过使用类似的幻灯片:函数(事件,ui){$(“#slider”).slider(“value”);var-valueslider=ui.value;$(“#amount”).val($”+valueslider);}但不起作用。我用错了吗?是的,你用错了<代码>$(“#滑块”)。滑块(“值”)将返回该值。所以你应该使用它如下
var-valueslider=$(“#slider”).slider(“value”)奇怪的是,当我把它放在0-100之间时,它只显示为数值,而不应该是。它应该显示我的数据库的值,因为我说这里@user1901142使用
min
max
选项。它只增加范围,我希望在输入armount上显示我的表值,而不显示该范围之间的数字。我的问题是。
$("#slider).slider({
    max: slideMax,
    min: slideMin,
    value: slideInit,

// To set the value to the `#amount` element, use the following `slide` event
    slide: function( event, ui ) {
        $( "#amount" ).val( ui.value );    
    }
});