我使用了jquery价格范围滑块。我想使用同一页上的jquery价格范围滑块筛选出结果。但这个jquery价格范围滑块不起作用,或者该值的变量不在同一页上。
我试过遵循密码,

    <?php
        if(isset($_POST['amount1']))
        {
          echo $_SESSION['amount1'] = $_POST['amount1'];
        }
        if(isset($_POST['amount2']))
        {
          echo $_SESSION['amount2'] = $_POST['amount2'];
        }
        if(isset($_POST['submit_range']))
        {
            $sql = mysql_query("select * from hall_search_data_1 where rent BETWEEN '".$_SESSION['amount1']."' AND '".$_SESSION['amount2']."'");
            $res = mysql_query($sql)or die(mysql_error());
        }
    ?>

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

<div class="slider">
  <div id="slider-range"></div>

  <form method="get">
    <input type="hidden" id="amount1">
    <input type="hidden" id="amount2">
    <input type="submit" name="submit_range" value="Submit">
  </form>
</div>

<!--here php code ---->

if(isset($_POST['amount1']))
{
echo $_SESSION['amount1'] = $_POST['amount1'];
}

if(isset($_POST['amount2']))
{
echo $_SESSION['amount2'] = $_POST['amount2'];
}

if(isset($_POST['submit_range']))
{


                            $sql = mysql_query("select * from hall_search_data_1 where rent BETWEEN '".$_SESSION['amount1']."' AND '".$_SESSION['amount2']."'");
                            $res = mysql_query($sql)or die(mysql_error());
                        }

所以请帮帮我。

最佳答案

<div class="slider">
  <div id="slider-range"></div>

  <form method="get">
    <input type="hidden" id="amount1">
    <input type="hidden" id="amount2">
    <input type="submit" name="submit_range" value="Submit">
   </form>
</div>

在您的表单中,您错过了name属性,因此您将得到
未定义索引:amount1,amount2
以上错误。
更新代码如下
<form method="get">
  <input type="hidden" id="amount1" name="amount1">
  <input type="hidden" id="amount2" name="amount2">
  <input type="submit" name="submit_range" value="Submit">
</form>

08-27 03:43