Jump to content
UBot Underground

Loading File Names Into UI HTML Dropdown


Recommended Posts

SOLVED!!!!!

 

Loading a list of files from a folder as option names in a dropdown.

So this was a really tough one. Several people helped with this one, and some people thought it wasn't possible to even do. Thanks to magoo, bill bogacz, and ubotsbiggestfan for help with getting this to work. This was several days of work to get this to function.

I have included the code below because I wouldn't want others to have to go through the nightmare that was this problem!

ui html panel("<select name=\"dropdownoptions\" style=\"width: 200px;\" variable=\"#dropdownoptions\" fillwith=\"value\">
{#options}
</select>", 200)
comment("Load dropdown options define command needs to be in the \"on load\" command in order for this to function properly.")
on load("Tab Loaded") {
    create test files()
    load dropdown options()
}
define load dropdown options {
    clear list(%dropdownoptions1)
    clear list(%dropdownoptions2)
    comment("Below sets the folder where to get files names from. You will need to change this to your own folder and edit the file extension as well.")
    set(#options, $replace($get files("{$special folder("Desktop")}\\test-dropdown", "No"), ".txt", $nothing), "Global")
    add list to list(%dropdownoptions1, $list from text(#options, $new line), "Delete", "Global")
    set(#options num, "-1", "Global")
    loop($list total(%dropdownoptions1)) {
        increment(#options num)
        add item to list(%dropdownoptions2, "<option value=\"{$list item(%dropdownoptions1, #options num)}\">{$list item(%dropdownoptions1, #options num)}</option>", "Delete", "Global")
    }
    set(#options, %dropdownoptions2, "Global")
}
comment("Creates test folder on the desktop named \"test-dropdown\".  ")
define create test files {
    create folder($special folder("Desktop"), "test-dropdown")
    set(#file num, 0, "Global")
    loop(5) {
        increment(#file num)
        save to file("{$special folder("Desktop")}\\test-dropdown\\test-{#file num}.txt", #file num)
    }
}
  • Like 1
Link to post
Share on other sites
  • 1 month later...

That was helpful for something I was trying to do.  Having trouble with it though... #dropdownoptions doesn't update when I pick an item from the dropdown.  Do I need javascript or something to set it? 

Link to post
Share on other sites

That was helpful for something I was trying to do.  Having trouble with it though... #dropdownoptions doesn't update when I pick an item from the dropdown.  Do I need javascript or something to set it? 

hmm it should update. It does for me.

 

wanna share your code and I can see what I can do.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...