0

I have a fulltext Filter for some Fields and would like to include a Filter for a Check if a number is <= 0

Here you see my script code and as well my HTML-Code

I'm working with ASP.NET and some ViewModels

    function filterResult() {
        var table, tr, i;
        table = document.getElementById("buchliste");
        tr = table.getElementsByTagName("tr");

        for (i = 0; i < tr.length; i++) {
            var td = tr[i].getElementsByTagName("td");

            if (
                td[0] && td[0].innerHTML.toUpperCase().indexOf(document.getElementById("katInput").value.toUpperCase()) > -1 &&
                td[1] && td[1].innerHTML.toUpperCase().indexOf(document.getElementById("titelInput").value.toUpperCase()) > -1 &&
                td[2] && td[2].innerHTML.toUpperCase().indexOf(document.getElementById("autorInput").value.toUpperCase()) > -1 &&
                td[3] && td[3].innerHTML.toUpperCase().indexOf(document.getElementById("isbnInput").value.toUpperCase()) > -1 &&
                td[4] && td[4].innerHTML.toUpperCase().indexOf(document.getElementById("buchBeschreibungInput").value.toUpperCase()) > -1 &&
                td[7] && td[7].innerHTML.toUpperCase().indexOf(document.getElementById("verfügbarInput").value.toUpperCase()) > -1 
            ) {
                tr[i].style.display = "";
            }
            else {
                tr[i].style.display = "none";
            }

        }
    }
 <details>
        <summary><label for="Liste filtern">Liste filtern</label></summary>
        <br />
        <div class="row">
            <div class="col-sm-2">

                <input class="form-control" type="text" id="katInput" onkeyup="filterResult()" placeholder="Kategorie" />
            </div>
            <div class="col-sm-2">

                <input class="form-control" type="text" id="titelInput" onkeyup="filterResult()" placeholder="Titel" />
            </div>
            <div class="col-sm-2">

                <input class="form-control" type="text" id="autorInput" onkeyup="filterResult()" placeholder="Autor" />
            </div>
            <div class="col-sm-2">

                <input class="form-control" type="text" id="isbnInput" onkeyup="filterResult()" placeholder="ISBN" />
            </div>
            <div class="col-sm-2">

                <input class="form-control" type="text" id="buchBeschreibungInput" onkeyup="filterResult()" placeholder="Buchbeschreibung" />
            </div>
            <div class="col-sm-2 ">
                <label>Verfügbar</label>
                <input class="checkbox-inline " type="checkbox" id="verfügbarInput" onkeyup="filterResult()" />
            </div>
        </div><br />
    </details>

On the 7th Index is the Field with some integer-Values.... The Checkbox == verfügbarInput

I also have another list on another view - where i have to filter with some price between min and max -

could someone help me to take advantage of this problem?

1
  • I wouldn't dare to use German umlauts for client-side elements like the "ü" in verfügbarInput. Commented Oct 14, 2018 at 20:17

2 Answers 2

1

Just get it and the use the hasAttribute function

document.querySelector('.checkbox-inline').hasAttribute('checked');
Sign up to request clarification or add additional context in comments.

Comments

0

Try this

document.querySelector('.checkbox-inline:checked').value;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.