如何在PHP中获得HTML5范围(2张幻灯片)Slider的值? [英] How to get HTML5 Range (2 slides) Slider's value in PHP?
本文介绍了如何在PHP中获得HTML5范围(2张幻灯片)Slider的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有此代码:
HTML :
<div class="unit">
<div class="slider-group">
Budget:
<label id="2-h"></label>
</div>
<div id="slider-2-h"></div>
<input type="hidden" name="sliderBudget" id="sliderValue" value="">
</div>
JavaScript :
$(function() {
$( '#slider-2-h' ).slider({
range: true,
min: 0,
max: 500,
values: [ 75, 300 ],
slide: function( event, ui ) {
$( '#2-h' ).html( '€' + ui.values[ 0 ] + ' - €' + ui.values[ 1 ] );
},
change: function(event, ui) {
$('#sliderValue').attr('value', ui.value);
}
});
$( '#2-h' ).html('€' + $('#slider-2-h' ).slider( 'values', 0 ) +
' - €' + $( '#slider-2-h' ).slider( 'values', 1 ) );
});
但是我的范围是-至,只有1个输入(隐藏). 我现在设置了一个次输入(隐藏),但是我们可以将secouund值发送到输入吗?
But I have a range from - to, and only 1 input (hidden). I set now a secound input (hidden) but we can is send the secouund value to the input?
我设置了秒数:
change: function(event, ui){
$('#sliderValue').attr('value', ui.value);
}
使用ui.value[1]
,但是不行
推荐答案
实现目标的简单方法是拥有两个输入字段.
The simple way to achieve your goal is having two input fields.
添加另一个具有不同名称的输入值.
Add another input value with different name.
<input type="hidden" name="sliderBudget2" id="sliderValue2" value="">
并更改您的change
事件以设置新的输入值.
And alter your change
event to set the new input value.
change: function(event, ui){
$('#sliderValue').attr('value', ui.value[0]);
$('#sliderValue2').attr('value', ui.value[1]);
}
这篇关于如何在PHP中获得HTML5范围(2张幻灯片)Slider的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文