Adding extra search text to a MediaWiki search query using InputBox

后端 未结 1 801
心在旅途
心在旅途 2021-01-15 05:20

We are using the InputBox extension. We want to have a search function using two checkboxes like this:

\"Search\

相关标签:
1条回答
  • 2021-01-15 05:54

    Tough one, you could try utilizing JavaScript to add a keyword you want when each of the checkboxes is selected. Something like so: (jQuery is used for comfort, but normal JS can be used as well if not an option):

    $("#search").submit(function(e) {
        var search_value = $('input[type="text"]', this).val();
        if ($("#checkbox1").checked) { search_value = "SomeValue " + search_value; }
        if ($("#checkbox2").checked) { search_value = "SomeOtherValue " + search_value; }
    
        $('#search input[type="text"]').val(search_value);
        $(this).submit();
        e.preventDefault();
    });
    

    Note, should the user disable JavaScript for some reason, your functionality will be damaged, which is always a bad practice. Only use this in case you've really extracted all other possibilities.

    0 讨论(0)
提交回复
热议问题