Implementing a price range slider Using the JQuery Ajax and PHP

 

 

How to implement a price range slider with jQuery  Ajax and PHP

 

 

 

coding-zon-js-range-slider-php

 

In last blog we worked on price slider with JavaScript and PHP. In this blog, we will do the same using jQuery Ajax request and PHP response. Here is the code example  to implement  price range slider using the jQuery  Ajax and PHP.

 Follow the steps given below:

Step-1:

We used the same PHP file as we did for JavaScript. So create the following PHP file with the given name and place the below given code in it.

current_prices.php


<?php echo " Price Min: ".$_GET['min']." Price Max: ".$_GET['max']; ?>



Step-2

Now  frontend code using HTML and jQuery. 

Create a php file with given name and copy the below code in it, and Save. Next open in Browser and run the file.

price-range-slider2.php

<!DOCTYPE html> 
 
<html>
 
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
 
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>

</head>
<body>

<div data-role="page">
<div data-role="header">
    <h1>Implementing a price range slider Using the jQuery  Ajax and PHP</h1>
    
</div>

<script>
    $(document).ready(function(){ 
        
        $("button").on("click", function(e){
            
            
            var price_min = $("#price_min").val();
            var price_max = $("#price_max").val();
             
            $.ajax({
                url: "current_prices.php",
                method: "GET",
                data: {min:price_min, max:price_max},
                success:function(response){
                    $("#demo").text(response);
                } 
            });
        });
    });
</script>

<div id="demo">
    <h2>PHP Response</h2>  
</div>




<div data-role="main" class="ui-content">
    
    <div data-role="rangeslider">
        <label for="price-min">Price:</label>
        <input type="range" name="price_min" id="price_min" value="200" min="0" max="1000">
        <label for="price-max">Price:</label>
        <input type="range" name="price_max" id="price_max" value="800" min="0" max="1000">
    </div>
    <button type="button">Click Here!</button> 
    
    <p>The range slider can be useful for allowing users to select a
    specific price range when browsing products.</p>
    
    
</div>


</div> 

</body>
</html>






Demo:



e-trainings-PriceRangeSlider-with-JQuery-PHP









































































 
 
 
 
 
 
 
 
 
 
 
 
 
 

Comments

Popular posts from this blog

Using javascript pass form variables to iframe src

Creating a new PDF by Merging PDF documents using TCPDF

Import excel file into mysql in PHP