Custom Filter & Selected Option Values

Forums SPJS Charts for SharePoint Custom Filter & Selected Option Values

Tagged: 

This topic contains 1 reply, has 2 voices, and was last updated by  Alexander Bautz 2 years, 7 months ago.

  • Author
    Posts
  • #7799

    HTIC
    Participant

    Hi Alex,

    I am trying to retreive the selected option value from my dropdown filter in my own variable but not quite sure how to. Are you able to advise me on which object will give me this data?

    Attachments:
  • #7981

    Alexander Bautz
    Keymaster

    Hi,
    Sorry for the late reply. I’m not 100% sure I understand what you mean, but you can add code like this to get the option in a variable:

    You must use the developer tools (hit F12 > DOM Explorer) to inspect the dropdown to find its ID – mine has the ID “f3cf96da-cfb5-43b8-b6c4-1024b8231639_CustomFilterSelect_FieldInternalName”:

    var selectedVal = $("#f3cf96da-cfb5-43b8-b6c4-1024b8231639_CustomFilterSelect_FieldInternalName").find("option:selected").val();
    alert(selectedVal);

    You can also set it up “live” like this:

    $("#f3cf96da-cfb5-43b8-b6c4-1024b8231639_CustomFilterSelect_FieldInternalName").bind("change",function(){
    alert("selected value: "+$(this).find("option:selected").val());
    });

    Hope this helps,
    Alexander

You must be logged in to reply to this topic.