SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    May 2010
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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?

  2. #2
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,609
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Google really is your friend for questions like this.
    Ian Anderson
    www.siteguru.co.uk

  3. #3
    SitePoint Member
    Join Date
    May 2010
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Tried that, but struggling, the real problem I've got is converting the [[Location]] array into something which will work within javascript.

  4. #4
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,609
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    So what does that array look like?
    Ian Anderson
    www.siteguru.co.uk

  5. #5
    SitePoint Member
    Join Date
    May 2010
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's it, All I see is [[Location]] which is full of values from a csv file I've imported.

  6. #6
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,609
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    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.
    Ian Anderson
    www.siteguru.co.uk

  7. #7
    SitePoint Member
    Join Date
    May 2010
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •