Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

combo box sorted order

Posted on 2009-07-13
2
Medium Priority
?
407 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 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

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…
Following on from our article on "The Murky World of Consent and opt in", we thought we would issue some helpful guidance, not only on consent itself but knowing what information you are capturing, what you are doing with this data and how you can p…
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…
This Micro Tutorial will demonstrate how nuggets on the Web are formatted by using Chrome Developer Tools. These tools would not only view the site's CSS but it can also modify it and save the CSS to use on your own site.
Suggested Courses

876 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