Multiple Search between

Multiple Search between

Taka HoTaka Ho Posts: 6Questions: 2Answers: 0

Hi

I followed this tutorial (https://datatables.net/examples/plug-ins/range_filtering.html) to search age using 2 values.

Is it possible to search between salary like min and max?
If so can you please provide me with some code.

Answers

  • Taka HoTaka Ho Posts: 6Questions: 2Answers: 0

    It is nearly working but I need to fill in age everytime.

    if ( ( isNaN( minAge ) && isNaN( maxAge ) ) ||
        ( isNaN( minAge ) && age <= maxAge ) ||
        ( minAge <= age   && isNaN( maxAge ) ) ||
        ( minAge <= age   && age <= maxAge ) &&
        (( isNaN(minSalary) && isNaN(maxSalary)) ||
            ( isNaN(minSalary) && salary <= maxSalary) ||
            ( minSalary <= salary && isNaN( maxSalary )) ||
            ( minSalary <= salary && salary <= maxSalary))
    )
    
    
    
  • Taka HoTaka Ho Posts: 6Questions: 2Answers: 0

    It is working! I needed to add an extra "()"

    if ( (( isNaN( minAge ) && isNaN( maxAge ) ) ||
        ( isNaN( minAge ) && age <= maxAge ) ||
        ( minAge <= age   && isNaN( maxAge ) ) ||
        ( minAge <= age   && age <= maxAge )) &&
        ((( isNaN(minSalary) && isNaN(maxSalary)) ||
            ( isNaN(minSalary) && salary <= maxSalary) ||
            ( minSalary <= salary && isNaN( maxSalary )) ||
            ( minSalary <= salary && salary <= maxSalary)))
    )
    
This discussion has been closed.