KB Article 15992

Contact Tech Support

 Email Tech Support
 (250) 655-1766
 [7:30 - 5:00 PST]
Your Meeting ID will be Provided by a Rep.
Tech Support
Tech Support Home
Software Updates
Knowledge Base Search
Recent KB Articles
Product FAQs
Code Samples
Tech Blog
System Requirements
Installation Instructions
Support Testimonials
Contact us to...
Create a Ticket
Request a Free Demo
Suggest a New Feature
Submit Feedback
Upload a Large File
Other Services
Software Training
Professional Services

Create drop down menu with a given list of numbers

Product: Presto Type: How to

Sometimes there might be need to create a drop down menu with specific range of numbers. Below are two easy ways of accomplishing that with SQL and JavaScript.


Go to Visual Editor, right button mouse click anywhere on a screen, select Common Elements and click on Drop Down List. It will create an empty drop down element.
In the Element Properties of drop down list insert the following code into Data Source/SQL Query:

SELECT ones.n + 10*tens.n,2,'0', ones.n + 10*tens.n 
FROM (VALUES(0),(1),(2),(3),(4),(5),(6),(7),(8),(9)) ones(n), 
(VALUES(0),(1),(2),(3),(4),(5),(6),(7),(8),(9)) tens(n) 
WHERE ones.n + 10*tens.n BETWEEN 1 AND 99 

This will give you the following result:

If you would like to pad the numbers with leading zeros, convert each ones.n + 10*tens.n,2,'0' in above SELECT statement as follows:

 lpad(ones.n + 10*tens.n, 2, '0')

In case you need more zeros, just change the second parameter to desired number.



First, you need to create an empty drop down element (see above). After that, attach to page the following JavaScript:

var selectList = "<select name='numbers'>";
for (var x = 1; x < 99; x++) {
    selectList += "<option value='" + x + "'>" + x + "</option>";
selectList += "</select>";

In the code above, substitute #your_dd_elem  with the id of your drop down list.


Keywords: drop down, dropdown, select, menu, SQL, javascript, list , range, numbers

Rate This Article

Did this example help you to achieve your goal?
 Yes  No  Don't Know

Enter additional comments below.   If you want to hear back from us, include your contact information.

Email Address:
Please enable JavaScript in order to rate this page.