Next to search box there is a dropdown
containing query suggestions (everything, people, ...). How can I catch the value of this dropdown
(it is div.s) in JavaScript (jQuery). Also I want to know which item has been chosen by the user in my JavaScript file.
1 Answer
You can via javascript set an eventhandler on the dropdown list. You can set the eventhandler to trigger on .change()
when it's a dropdownlists.
An example would be:
[In your masterpage]
$("DropDownListClientID").change(function () {
GetSelectedSearch($(this + " option:selected"))
});
[In your .js file]
function GetSelectedSearch(selection)
{
// your code here
}
-
thank you for your answer. In my js file I send query to search by uing Search Rest API and the result is shown in a div like a mega menu. I wanted to restrict the query by catching the value of this dropdownlist. the problem is this is not a realy dropdownlist but only divs. I am going to test your answer and will mark it as answer. Feb 24, 2013 at 17:02