1

Onload of the page: 1. Change the selected value of dropdown 2. DFWP will update list

I have a dropdown list connected to a DFWP for filtering. Using javascript and onload function of SharePoint, I would like to pick a dropdown menu option using:

setSelectedIndex2(document.getElementById("ctl00_PlaceHolderTopNavBar_DropDownList1"),"General"); 

default menu option is "Brand": the option shows another list

I want to change the DFWP default value to General using js

_spBodyOnLoadFunctionNames.push("MyFunctionName");

function MyFunctionName()
 {
    $('#ctl00_PlaceHolderTopNavBar_DropDownList1').change(test).change();
 {
 function test()
 {
    $( "#ctl00_PlaceHolderTopNavBar_DropDownList1" ).change(function() 
    {  
       setSelectedIndex2(document.getElementById("ctl00_PlaceHolderTopNavBar_DropDownList1"),"General");
    });
});

result of this script: The page reload non stop and keeps executing the test function.

Hope you can help me with this. Thanks

  • You only want to trigger the change() when the current value is not equal to General. You are now performing the change on every pageload – Danny '365CSI' Engelman Feb 17 '16 at 14:34
  • Yes. I am changing the list depending on the user information extracted from the active directory. I even use a __doPostBack('ctl00_PlaceHolderTopNavBar_DropDownList','');, . same result. Page keeps reloading – Fiere Feb 18 '16 at 2:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.