Filtering between Select Box Salary ranges

Filtering between Select Box Salary ranges

mckvrmckvr Posts: 1Questions: 1Answers: 0

I'm trying to filter Salaries in a DataTable using a select box but I'm not sure what I'm doing wrong.

Here's the select box:

    <select class="custom-select w-100" name="salary" id="salary">
    <option value="" selected="selected">Any salary</option>
    <option value="18000">£18,000 and below</option>
    <option value="28000">£28,000 and below </option>
    <option value="32000">£32,000 and below</option>
    <option value="40000">£40,000 and above</option>
    </select>

And here's the query:

    $.fn.dataTable.ext.search.push(function (settings, data, dataIndex) {
          var salary = parseFloat( data[2].replace(",","") ) || 0;
          return salary <= parseInt($('#salary').val())
          });
    
    $('#salary').on( 'change', function (data) {
            table.draw();
          });

Here's a link to the live version: https://hs.littledev.net/jobs/

I've attached a picture of the table.

Does anyone know what I'm doing fundamentally wrong? I imagine it's something obvious..

Answers

  • tangerinetangerine Posts: 1,880Questions: 8Answers: 206

    One of your salaries is "Excellent", which can't be helping.

Sign In or Register to comment.