-1

I have a repeated dropdown hidden list (tfa_1043) in FormAssembly and when a value is changed I need the displayed dropdown list (tfa_4) option value selection to equal tfa_1043 selection

  function getSelectedValue(){    
  var x = document.getElementById("tfa_43").selectedIndex;
  var y = document.getElementById("tfa_43").options;

  //change the index number of each dropdown to match event dropdown index
  document.getElementById("tfa_1043").selectedIndex = y[x].index;//HIDEN-LOCATION

  var z = document.getElementById("tfa_1043")
  var i = z.selectedIndex;
  document.getElementById("tfa_4").options.value = z.options[i].text;//DISPLAYED LOCATION
   return;


}  

// 

);
6
  • what is the context of this code. Lightning, VF, vf component, lightning component?
    – Himanshu
    Commented Oct 3, 2018 at 17:19
  • I'm using a form builder called FormAssemmbly that is connected/integrated to Sales Cloud. The form allows me to add JavaScript and I'm trying to manipulate a dropdownlist based on a mapped picklist from SF to the form. Commented Oct 3, 2018 at 17:29
  • Robert, welcome to SFSE! I want to encourage you read our How to Ask page. On that note, I'd like to point out that your question is really a javascript question, not really a salesforce one. Because of that, I'd like to suggest you hit the "Stack Overflow" forum where you'll likely get a lot of better answers. If your question does have a relation to the salesforce plaftorm, I encourage you to edit your question with more detail, showing how salesforce-specific components or pages are affected Commented Oct 3, 2018 at 17:56
  • We wouldn't normally address non-Salesforce-related questions in this form, but we use FormAssembly where I work. I'll see if any of my coworkers can point you in the right direction. Commented Oct 4, 2018 at 0:21
  • @Himanshu -- it's Javascript used inside a product called FormAssembly, which, without any code in theory, lets you buid dynamic webforms that interface with Salesforce, among other systems. Obviously the, "without code," part isn't always true! Commented Oct 7, 2018 at 15:47

1 Answer 1

2

Assuming that each of the drop downs tfa_43, tfa_1043, and tfa_4 have the same options set for them. Then it seems like you just need to set the selectedIndex for each equal to x.

function getSelectedValue(){    
    var x = document.getElementById("tfa_43").selectedIndex;

    //change the index number of each dropdown to match event dropdown index
    document.getElementById("tfa_1043").selectedIndex = x;  //HIDEN-LOCATION

    document.getElementById("tfa_4").selectedIndex = x;   //DISPLAYED LOCATION
    return;
}

Not the answer you're looking for? Browse other questions tagged .