Josh 37 Posted March 4, 2013 Report Share Posted March 4, 2013 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) } } 1 Quote Link to post Share on other sites
Josh 37 Posted March 6, 2013 Author Report Share Posted March 6, 2013 SOLVED!!!!! Quote Link to post Share on other sites
J Bot 5 Posted April 9, 2013 Report Share Posted April 9, 2013 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? Quote Link to post Share on other sites
Josh 37 Posted April 9, 2013 Author Report Share Posted April 9, 2013 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. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.