Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

combo box sorted order

Posted on 2009-07-13
2
Medium Priority
?
405 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 2000 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

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

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

I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
This article offers some helpful and general tips for safe browsing and online shopping. It offers simple and manageable procedures that help to ensure the safety of one's personal information and the security of any devices.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This video teaches viewers about errors in exception handling.
Suggested Courses

715 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