Patrick Seewald
Patrick Seewald

Reputation: 1

Check status of checkbox

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?

Upvotes: 0

Views: 66

Answers (2)

Dhana
Dhana

Reputation: 1658

Try this

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

Upvotes: 0

user10504169
user10504169

Reputation: 11

Just get it and the use the hasAttribute function

document.querySelector('.checkbox-inline').hasAttribute('checked');

Upvotes: 1

Related Questions