Solved

combo box sorted order

Posted on 2009-07-13
2
399 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
iterator/ListIterator approach 17 41
Running JavaFX on JDeveloper 12C 1 55
How to configure empty element in XML Document parser? 15 36
junit as external jar or library 7 24
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

821 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