mardi 26 mai 2020

Set input integer value in reference to other integer input value to performe a search

I'm trying to create a search filter that allows me to search items in my store. So I have 2 inputs and I want to be able to do the following.

1- If my minimum price is empty then return 0 as a value to perform the search 2- If maximum price is lower than minimum price then change the maximum price input into minimum price + 1 to perform the search 3- If maximum price is empty then return infinite (or a really big number like 1000000) to perform the search

I've tried to create the script following that, but it doesn't work. So I'm not sure what I'm doing wrong. This is the html with the script.

Thank you so much for taking the time to help me!!

<form method="get" action="https://magiccarpets.online/shop/" target="_self">
       <div class="custom_range_widget">
        <input type="number" name="min_price" min="0" max="50000" placeholder="Min." contenteditable="true" id="minprice" />
        <input type="number" name="max_price" min="0" max="50000" placeholder="Max." contenteditable="true" id="maxprice" />
            <script>
            function  PriceRange() {
            var input = document.getElementById("maxprice"),
                input = document.getElementById("minprice");

                if ((int)mminprice == "") {
                        (int)document.getElementById("mminprice").innerHTML = (int)0;
                }

                if ((int)maxprice <= (int)minprice){
                        (int)document.getElementById("maxprice").innerHTML = ((int)document.getElementById("minprice").innerHTML + (int)1);
                }

                if ((int)maxprice == "") {
                        (int)document.getElementById("maxprice").innerHTML = (int)1000000;
                }
            }
            </script>
            </div>
        <button type="submit" class="button">Filter</button>
   </form>

Aucun commentaire:

Enregistrer un commentaire