• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to sort List Box

 
Vipin Sahu
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Vipin Sahu
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why use the display text? Why not use the value which doesn;t need to be split?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic