• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to sort List Box

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why use the display text? Why not use the value which doesn;t need to be split?
 
reply
    Bookmark Topic Watch Topic
  • New Topic