gpt4 book ai didi

javascript - 使用 PHP 获取价格范围的值

转载 作者:行者123 更新时间:2023-11-30 22:51:49 25 4
gpt4 key购买 nike

我正在使用类似的价格范围: http://jsfiddle.net/dhana36/b453V/2/

我希望能够使用 PHP 从以下 javascript 函数中获取价格范围内的最小值和最大值:

 $(function() {
$( "#slider-range" ).slider({
range: true,
min: 0,
max: 2000,
values: [ 300, 1000 ],
slide: function( event, ui ) {
$( "#amount" ).val( "$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ] );
}
});
$( "#amount" ).val( "$" + $( "#slider-range" ).slider( "values", 0 ) +
" - $" + $( "#slider-range" ).slider( "values", 1 ) );
});

以下是我要实现的目标:

$p1 = value from minimum value;
$p2 = value from maximum value;
$get_crs = mysql_query("SELECT * FROM products where product_price BETWEEN '$p1' AND '$p2' ORDER BY product_date1");

因此,我的问题如下:我有一个 slider ,搜索结果是按最低和最高价格动态过滤的,我的问题是如何填写以下空白:

   $p1 = blank;
$p2 = blank;

注意:如果您对它的 html 部分感到好奇,下面是代码:

  <label for="amount" id="Price">Price Range</label><br>
<input type="text" id="amount">
</p>
<div id="slider-range"></div>

如果您需要任何说明,请告诉我。

最佳答案

//bul.php or other send methots...
<?
if($_POST)
{
$_POST['amount'];
$values = str_replace(' ','',$_POST['amount']);
$values = str_replace('$','',$values);
$values = explode('-',$values);
$min = $values[0];
$max = $values[1];

$HTML='';
};
echo $min;
echo $max;
?>

//html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Başlıksız Belge</title>
<script type="text/javascript" src="//code.jquery.com/jquery-1.9.1.js"></script>




<script type="text/javascript" src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css">

<link rel="stylesheet" type="text/css" href="/css/result-light.css">


<link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<script>
$(function() {
$('select').change(function(){
$( "#amount" ).val( $('select').val() + $( "#slider-range" ).slider( "values", 0 ) +
" - "+ $('select').val() + $( "#slider-range" ).slider( "values", 1 ) );
})
$( "#slider-range" ).slider({
range: true,
min: 50,
max: 10000,
values: [ 75, 300 ],
slide: function( event, ui ) {
$( "#amount" ).val( $('select').val() + ui.values[ 0 ] + " - "+ $('select').val() + ui.values[ 1 ] );
}
});
$( "#amount" ).val( $('select').val() + $( "#slider-range" ).slider( "values", 0 ) +
" - "+ $('select').val() + $( "#slider-range" ).slider( "values", 1 ) );
});
</script>
</head>
<body>
<form action="bul.php" method="post">
<div style="margin-left:20px">
<select name=currency class="f15">
<option value="" selected>TL</option>
</select>
<label for="amount">Price range:</label>

<input type="text" id="amount" name="amount" style="border:0; color:#f6931f; font-weight:bold;" readonly>
<br><br>
<div id="slider-range" style="width:80%;"></div>
<br><br>
<input type="submit" value="Show Prices " />
<br><br>
</div>
</form>
</body>
</html>

关于javascript - 使用 PHP 获取价格范围的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27968607/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com