This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes How to sort List Box Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to sort List Box" Watch "How to sort List Box" New topic
Author

How to sort List Box

Vipin Sahu
Greenhorn

Joined: Mar 08, 2007
Posts: 6
Hi,

I have a list box and I need to sort it on column wise.
We are using <select> tag for generating list.

Here i am attaching the code for generating list box and the links on the top for sorting.

Please help me.


<table border="0" cellpadding="0" cellspacing="0" width="98%">

<tr>
<td>
<TABLE width="35%">
<tr>
<td><a href="javascript:sort('no')">SE No </a></td>
<td><a href="javascript:sort('level')">Hier Level</a></td>
<td><a href="javascript:sort('type')">Map</a></td>
</tr>
</TABLE>
</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>
<select name="dependantSEs" size=5 MULTIPLE onChange="">
<option value="1030005532"><font class="formated" >1030005532             2354786320      SE</font></option>
<option value="1030025902"><font class="formated" >1030025902             9658742513      SE</font></option>
<option value="1030058580"><font class="formated" >1030058580             8751246201      SE</font></option>
<option value="1030060883"><font class="formated" >1030060883             N/A      SE</font></option>
<option value="1030065528"><font class="formated" >1030065528             N/A      SE</font></option>
<option value="1030117618"><font class="formated" >1030117618             N/A      SE</font></option>
<option value="1030202279"><font class="formated" >1030202279             N/A      SE</font></option>
<option value="1036509354"><font class="formated" >1036509354             2548701547      CAP</font></option>
<option value="1036547818"><font class="formated" >1036547818             N/A      SE</font></option>
<option value="4103602769"><font class="formated" >4103602769             1546982015      SE</font></option>
<option value="4450508163"><font class="formated" >4450508163             N/A      CAP</font></option>
</select>
</td>
</tr>
</table>
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61104
    
  66

Are you familiar with sorting algorithms? If so, just grab the values from the options and use them to sort the options as you would any other data.

Which part has you blocked?
[ July 16, 2007: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Vipin Sahu
Greenhorn

Joined: Mar 08, 2007
Posts: 6
I am unable to spit the string into three strings.
I don't have hands on javascript, so please guide me how to do this?

Thanks in advance.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61104
    
  66

Why use the display text? Why not use the value which doesn;t need to be split?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to sort List Box