Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Using checkboxes with jQuery in custom advanced search form

$
0
0

Hi,

I've created a custom advanced search screen for my users. I have the string fields figured out fine, but I'm hitting a snag with the checkboxes.

One of their requests was to have a series of checkboxes that would limit the results to only thedocument type(s) they selected. When a user hits the search button, their parameters are submitted to a typical SharePoint search URL, and then they are taken to the search results page. I'm not much of a coder at all, and cannot figure out how to get only the selected checkboxes inserted into the search string. Here is what I have so far. 

'use strict';

//var context = SP.ClientContext.get_current();
var collListItem = '';
var SearchURL = 'https://SITE.sharepoint.com/sites/SITESearch/Pages/Results.aspx?k=(StreamOWSText%3D%22Structures%22%20OR%20StreamOWSText%3D%22Structure%22)%20';

$(document).ready(function () {
        $("#SearchButton").click(function () {
        var searchCriteria = "";

        var LS = $("#LS").val();
		var BMP = $("#BMP").val();
        var EMP = $("#EMP").val();
		var DocumentType = $("#DocumentType").val();
		}

        if (LS !=="") {
            searchCriteria = searchCriteria + "RefinableInt11%3D" + LS + "%20AND%20";
        }
		if (BMP !=="") {
            searchCriteria = searchCriteria + "RefinableDecimal05%3E" + BMP + "%20AND%20";
        }
        if (EMP !=="") {
            searchCriteria = searchCriteria + "RefinableDecimal06%3C" + EMP + "%20AND%20";
		}
        if (DocumentType =="All") {
			searchCriteria = searchCriteria + "%20AND%20";
		}
		else {
			searchCriteria = searchCriteria + "RefinableString11%3D" + DocumentType + "%20AND%20";
		}

		if (searchCriteria !== "")
            searchCriteria = "(" + searchCriteria + ")";

        //window.location.reload(SearchURL + searchCriteria);
		//window.location.href(SearchURL + searchCriteria);
		setTimeout(function () { window.location.href = SearchURL + searchCriteria }, 100);

        //parent.location.href(SearchURL + searchCriteria);


    });
});


Viewing all articles
Browse latest Browse all 7589

Trending Articles