title: How can I select Price range with Input provided in textbox in jquery?
body: <p>I have one DropDownList which contains price range as depicted below</p>
  
  <ul>
  <li>Up to 50L  </li>
  <li>50L to 1CR</li>
  <li>1CR to 5CR  </li>
  <li>5CR to 10CR</li>
  </ul>
  
  <p>I also have one textbox which allows users to put input price in textbox. Now I want whenever user provides some valid price money then selected item should be set as per given price. e.g. if I put 2345 or 543245 or 887 then DropDownList's selected item should be <strong>Up to 50L</strong> and if I put 8432321 then selected value should be <strong>50L to 1CR</strong>. I have tried to put the following code for that but not working as per expectation.</p>
  
  <p>Javascript Code:</p>
  
  <pre><code>jQuery(function ($) {
          debugger;
          $('#txtPrice').on('change', function () {
              var value = parseInt(this.value, 10),
              dd = document.getElementById('ddlPriceRange'),
              index = 0;
  
              $.each(dd.options, function (i) {
                  if (parseInt(this.text, 10) &lt;= value) {
                      index = i;
                  }
              });
  
              dd.selectedIndex = index; // set selected option
          });
      });
  </code></pre>
  
  <p>.ASPX Code:</p>
  
  <pre><code>&lt;asp:DropDownList ID="ddlPriceRange" runat="server" ClientIDMode="Static"/&gt;
  &lt;asp:TextBox ID="txtPrice" runat="server" ClientIDMode="Static"/&gt;
  </code></pre>
  
  <p>Output which is being produced with above given code is given below</p>
  
  <p><a href="https://i.stack.imgur.com/D1VAU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/D1VAU.png" alt="Currect output is produced like given"></a></p>