Solved

combo box sorted order

Posted on 2009-07-13
2
396 Views
Last Modified: 2013-11-23
Hi All,
    I am retrieving values from database and inserting into combo box.
in SELECT statement i used, order by ASC. the values are comming in ascending order but when i see the values in combobox, then are not in sorted order. Can someone please tell me how to display combobox in sorted order.
Thanks,
0
Comment
Question by:keerthimothukuri
2 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 24840830
How are you getting them into the combo? (please post code)
0
 
LVL 8

Accepted Solution

by:
WhiteMage earned 500 total points
ID: 24841514
Does this help?
//SQL Query

'SELECT * FROM Table ORDER BY Field ASC'
 

//XHTML

<body>

  <select id="combobox">

    <option>&nbsp;</option>

  </select>

</body>
 

//Javascript

var rows; //rows from sql query

var select = document.getElementById('combobox');
 

while(select.hasChildNodes()) {

  select.removeChild(select.firstChild);

}
 

for(var i = 0; i < rows.length; i++) {

  var option = document.createElement('option');

  option.appendChild(document.createTextNode(rows[i]));

  select.appendChild(option);

}

Open in new window

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
#Citrix #Internet Explorer #Enterprise Mode #IE 11 #IE 8
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now