Home | Free Lite Version | Buy Now | Free Bonuses | Free Stuff | Links



Popup ComboBox Dialog

The xDialog Popup ComboBox dialog can be used as an alternative to the AMS ListBox or ComboBox objects. It can be used for simple lists with a few items or large lists with thousands of items. Items can be hard coded in, loaded from a Lua table, a text file or an SQLite database.

Using a lot of AMS ComboBox objects with a large amount of items on one page can really slow down page loads because you have to load the data into each ComboBox when the page loads. With the xDialog Popup ComboBox, you only load the list when it is needed.

You can set the items to display, the title, the width and the height. See the example code below.

Download Demo Application to see it in action.

 

These examples assume that the xDialog functions have been added to the Global functions. You can easily do this using the Add Code button on the Script Editor.

Example 1


-- Create a lua table and add some items to display in the combobox
tItems = {}

tItems[1] = "Red"
tItems[2] = "Green"
tItems[3] = "Blue"
tItems[4] = "Orange"
tItems[5] = "Yellow"
tItems[6] = "Pink"

-- Combine all the items into a string using "|" as a delimiter.
-- You must add a "|" to the end of the string
sItems = Table.Concat(tItems, "|", 1, TABLE_ALL).."|"

-- Show the listbox and pass it the list of items to display
Item = xDialog.Show_ComboBox("Please choose an item", sItems, 130, 125)

-- If an item was selected, then add it to the input field.
if Item ~= "CANCEL" then
   Input.SetText("Input1", Item)
end

 


Example 2


-- Create a lua table and add 500 items to it using a For Loop, to display in the combobox
tItems = {}

for n=1, 500 do
   tItems[n] = "Item number "..n
end

-- Combine all the items into a string using "|" as a delimiter.
-- You must add a "|" to the end of the string
sItems = Table.Concat(tItems, "|", 1, TABLE_ALL).."|"

-- Show the listbox and pass it the list of items to display
Item = xDialog.Show_ComboBox("Please choose an item", sItems, 130, 125)

-- If an item was selected, then add it to the input field.
if Item ~= "CANCEL" then
   Input.SetText("Input1", Item)
end

 

Copyright © 2007 All Rights Reserved