duanpao4522 2018-09-12 11:16
浏览 84

如何通过POST将双滑块最小值和最大值发送到PHP

I am trying to send min val and max val to php using submit via dual slider bar

The static page call the server php

    <?php include('server/server.php') ?>

JS code is down below

  <script>$( function() {
$( "#slider-range" ).slider({
  range: true,
  min: 18,
  max: 100,
  values: [ 18, 30 ],
  slide: function( event, ui ) {
    $( "#amount" ).val( "$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ] );
  }
});
$( "#amount" ).val( "$" + $( "#slider-range" ).slider( "values", 0 ) +
  " - $" + $( "#slider-range" ).slider( "values", 1 ) );  } );  </script>

And HTML Code is Looks down below At the moment, i have only submit the age. However, i want to send Min val and Max val.

<form action = "edit_preference2.php" method = "POST">   
<p>
  <label for="amount">Show Me:</label>
  <!--At the Moment it's only send 'AGE' 
  However i want to send min and max to PHP -->
  <input type="text" id="age" name = "age" readonly style="border:0;             color:#f6931f; font-weight:bold;">
</p>

<div id="slider-range"></div>
<button type="submit" name="btn_preference">Submit</button>
</form> 

I am trying to send this Min and Max value of Slider var to PHP

And in my PHP server. receive the data like down below

if (isset($_POST['btn_preference'])) 
{
$amount = $_POST["age"];
#How can i receive min and Max val ?? 
$_SESSION = $amount;
}
  • 写回答

2条回答 默认 最新

  • downing1988 2018-09-12 11:28
    关注

    Create 2 hidden inputs with name and id as min and max, then in your event

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

    then you'll just access them in your PHP as

    if (isset($_POST['btn_preference'])) 
    {
    $amount = $_POST["age"];
    $min = $_POST["min"];
    $max = $_POST["max"];
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 python变量和列表之间的相互影响
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)