JQuery Search Box with Bootstrap Accordion
Go to solution
Solved by Guest,
Example of the Javscript
$('#SoftwareSearchBar').on('input', function(e){ var softwareSearchItems = $('#softwareAccord').children(); $(softwareSearchItems).hide(); for(var i = 0; i < softwareSearchItems.length; i++){ if(($(softwareSearchItems).eq(i).attr('name').toLowerCase()).indexOf($(this).val().toLowerCase()) === 0){ $(softwareSearchItems).eq(i).show() } } });
Example of the Search Bar
<div class="panel panel-default"> <div class="panel-body"> <input type="search" name="SoftwareSearchBar" id="SoftwareSearchBar" class="form-control" placeholder="Search"> </div> </div>
Example of the Items
<div class="panel-group" id="softwareAccord"> <?php $query = mysqli_query($connect, "SELECT * FROM Software ORDER BY OS_ID ASC") or die(mysql_error()); while ($Software = mysqli_fetch_assoc($query)) { ?> <div class="panel panel-default" name="<?php echo $Software['Name']; ?>"> <div class="panel-heading"> <h4 class="panel-title"> </h4> </div> <div id="collapseSoftware<?php echo $Software['ID']; ?>" class="panel-collapse collapse"> <div class="panel-body"> </div> </div> </div> <?php } mysqli_free_result($query); ?> </div>
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now