Jump to content

Search for a notice in a noticeboard


Graham Quince

Recommended Posts

Inspired by Radclyffe school's forum search, here similar for searching for a notice.  I was using a noticeboard as a way of sharing websites and needed a quick way to refine it:

<style>
    .searchnotices {
        border: 1px solid #CCCCCC;
        border-radius: 7px;
        padding: 15px;
        font-size: 16px;
    }

</style>
<div class="searchnotices">
    Search websites: <input type="text" class="notice-search" placeholder="Search for a link">
</div>

<script>
// div widget UUID that contains the forum
var noticeboardUUID = '048F190620028747CDCE4F6E1234D503E8CC344CFE08E98D';
var searchBox = arguments[0].find('.notice-search');
searchBox.on('keyup', function(){
        
    var searchTerm = searchBox.val().toLowerCase(),
        notices = $('div[data-content-uuid="' + noticeboardUUID + '"]').find('.notice-table');

    $.each(notices.find('.topic-row'), function (key, notice) {
        if ($(this).text().toLowerCase().indexOf(searchTerm) > -1 || searchTerm.length < 1) {
            $(this).show();
        } else {
            $(this).hide();
        }
    });           
});
</script>

Radclyffe's original version for searching forums: https://www.frogeducation.com/community/training/html-tutorials/searching-forums

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...