Jump to content
Graham Quince

Search for a notice in a noticeboard

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...