Can javascript be used to get data from a remote server and populate a dropdown list? | XM Community
Solved

Can javascript be used to get data from a remote server and populate a dropdown list?

  • 8 May 2018
  • 1 reply
  • 46 views

Badge +1
New user alert:

I'm able to authenticate users via both SSO and by associating the user with a panel.

The panel entries contain embedded data fields that tell me various things, like the user's unit_ID (which department or office they're associated with).

Each unit has anywhere from 1 to 15 account numbers (nearly 400 numbers total).

I'd like to present users with a dropdown list of only the account numbers associated with their unit.

Because there are nearly 190 units, and because new account numbers are added periodically, I'd like to avoid using display logic if at all possible.

I know (or at least, I think) that javascript can be made to get data from a remote server if the data is formatted properly (I can put my data in JSON), and could filter the responses (match on unit_ID) and populate my dropdown list.

But that's all I know.

I have to be able to connect to a remote server, identify a file, filter by unit_ID, return the account numbers, and populate a dropdown list.

I'm not asking anyone to write the code for me, but maybe just point me in the right direction.

Any help would be greatly appreciated.
icon

Best answer by TomG 8 May 2018, 15:27

View original

1 reply

Userlevel 7
Badge +27
Use ajax to get data from a remote server using JavaScript. An issue you'll face is that it will be a cross domain request (Qualtrics to your domain). So, your web script will have to be configured for CORS (Cross-Origin Resource Sharing).

Since the unit_ID is coming from the panel (i.e. you won't be selecting unit_ID and account numbers on the same page), it might be easier to use a web service call and pipe your account numbers into the drop-down. Allow for the maximum number of account numbers per unit_ID and add display logic to any that are beyond the minimum number of account numbers per unit_ID.

Leave a Reply