Populating a Dropdown from an Array

Hi

I’m fairly new to programming and trying to resolve what seems like a basic problem.

I am using Moodle and need to make an amendment in one of the modules using a little bit of Javascript.

I have an array called [[Loacation]] I want to create a dropdown in an HTML from which will populate from this array. I could probably just about do it in php using the foreach command, but I need to be able to do it clientside using Javascript.

Can anyone offer me any pointers?

So what does that array look like?

Google really is your friend for questions like this. :slight_smile:

Tried that, but struggling, the real problem I’ve got is converting the [[Location]] array into something which will work within javascript.

The missing link here is - how do you know that this is an array? WHERE is it coming from? HOW are you getting it?

Caveat: I have no knowledge of Moodle. I have no idea what it is or what it does.

Moodle is an LMS with several modules built into it. One is a database module which can display records uploaded to it from a csv file.

Each field becomes an array of values depending on which record you are displaying.

One of these fields I have called Location which produces the array [[Location]]

What I want to do, is in the search function, create a dropdown list of all the values in this array so the user can select which location they are interested in and then display all records which hold this information, otherwise I am reliant on the user spelling the locations correctly.

That’s it, All I see is [[Location]] which is full of values from a csv file I’ve imported.