Solved

combo box sorted order

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Chrome NET_ERR_CERTIICATE_TRANSPARENCY_REQUIRED 2 180
Internet Explorer Certificate error 9 27
ForLoop Example 3 40
how to install java on RHEL image on EC2 4 7
Do you come here a lot? Are you lazy like me and don't want to go through the "trouble" of having to click your Dock's Safari icon and then having to click your Experts Exchange Favorites bookmark to get here? Well then this article is for you.
Citrix XenApp, Internet Explorer 11 set to Enterprise Mode and using central hosted sites.xml file.
The viewer will learn how to implement Singleton Design Pattern in Java.
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.

867 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

21 Experts available now in Live!

Get 1:1 Help Now