0

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 1

0

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
}
1
  • 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.
    – user12955
    Feb 24, 2013 at 17:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.