SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Addict
    Join Date
    Jun 2001
    Location
    Malaysia
    Posts
    352
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    sorting OPTION values by alphabetical order

    hey guys,

    just wondering... is there a quick n dirty way to auto-arrange OPTION values by alphabetical order? I've got tons of OPTION values, and they appear in the order I created them. Would like to have them sorted.

    My code snippet as follows:

    <option value="MS Office 2000">MS Office 2000</option>
    <option value="MS Office XP">MS Office XP</option>
    <option value="MS Outlook">MS Outlook</option>
    <option value="Windows ME">Windows ME</option>
    <option value="Windows Media Player">Windows Media Player</option>
    <option value="Windows 2000">Windows 2000</option>
    <option value="Windows XP">Windows XP</option>
    <option value="Windows NT">Windows NT</option>
    <option value="webEx">webEx</option>
    <option value="Instant Messaging">Instant Messaging</option>
    <option value="IRL World Dialler">IRL World Dialler</option>
    <option value="MS Excel">MS Excel</option>
    <option value="MS Access">MS Access</option>
    <option value="MS FrontPage">MS FrontPage</option>
    <option value="MS Internet Explorer 5">MS Internet Explorer 5</option>
    <option value="MS Internet Explorer 5.5">MS Internet Explorer 5.5</option>
    <option value="MS Internet Explorer 6.0">MS Internet Explorer 6.0</option>
    <option value="MS Powerpoint">MS Powerpoint</option>
    <option value="MS Project">MS Project</option>
    <option value="Netmeeting">Netmeeting</option>
    <option value="MS Visio">MS Visio</option>
    <option value="WinZip 8.0">WinZip 8.0</option>
    <option value="IRL-VPN">IRL-VPN</option>
    <option value="DSL">DSL (Non Supported)</option>
    <option value="SOHO">SOHO</option>
    <option value="SoftID">SoftID</option>
    <option value="SecurID">SecurID</option>
    <option value="Wireless">Wireless (WiFi)</option>
    <option value="AudioBridge">AudioBridge</option>

    and so on...

  2. #2
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Where do you have those string stored? Try putting them into a database and then create the option boxes dinamically, what would be your best choice.

    Paul

  3. #3
    SitePoint Addict
    Join Date
    Jun 2001
    Location
    Malaysia
    Posts
    352
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Paul S
    Where do you have those string stored? Try putting them into a database and then create the option boxes dinamically, what would be your best choice.

    Paul

    well, they're stored in an ASP file (my site's ASP driven with a SQL Server d/b backend).

    Is there any way of doing this other than generating the options via a d/b?

  4. #4
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    It's either manual (i.e. do it yourself), or put it in a database and sort alphabetically in your query. From the looks of things I'd say it would be best to throw this in a database anyway, especially if you change it a lot.

    --Vinnie

  5. #5
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by infinitium
    Is there any way of doing this other than generating the options via a d/b?
    Well if I wasn't allow to put those strings into a database then I'd use an editor that would help me to remove the html tags and leave only the strings (you can create and ASP or PHP script to do this too), then I'd use Excel to simply sort them.

    Paul

  6. #6
    gingham dress, army boots... silver trophy redux's Avatar
    Join Date
    Apr 2002
    Location
    Salford / Manchester / UK
    Posts
    4,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it's late, so i won't bother attempting to write asp code (which i'm bad at anyway), but i'd just put all those options in an array if i didn't have access to a database, sort the array programmatically, then do a loop to generate the options...
    re·dux (adj.): brought back; returned. used postpositively
    [latin : re-, re- + dux, leader; see duke.]
    WaSP Accessibility Task Force Member
    splintered.co.uk | photographia.co.uk | redux.deviantart.com

  7. #7
    SitePoint Addict
    Join Date
    Jun 2001
    Location
    Malaysia
    Posts
    352
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by redux
    it's late, so i won't bother attempting to write asp code (which i'm bad at anyway), but i'd just put all those options in an array if i didn't have access to a database, sort the array programmatically, then do a loop to generate the options...
    yeah, i figured that would be the only way.. oh well... thanks anyway!

  8. #8
    SitePoint Member
    Join Date
    Sep 2003
    Location
    Maryland
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try creating a recordset on the fly and using its sort method:

    Dim myObject
    Set myObjects = myObject
    Dim myRecordset
    Set myRecordset =CreateObject("ADODB.RecordSet")
    myRecordset.CursorLocation = 3 'client location
    myRecordset.Fields.Append "myField1", 200, 100 'varchar 100 long
    myRecordset.Fields.Append "myField2", 200, 400 'varchar 400 long
    myRecordset.Open

    For Each myObject In myObjects
    myRecordset.AddNew
    myRecordset.Fields("myField1").Value = myObject.myCollection("myField1").value
    myRecordset.Fields("myField2").Value = myObject.myCollection("myField2").value
    myRecordset.Update
    Next

    myRecordset.sort = "myField1 " & " DESC"
    myRecordset.MoveFirst

    While Not myRecordset.EOF
    response.write myRecordset.Fields("myField1").Value & ", " & myRecordset.Fields("myField2").Value & "<br>
    myRecordset.MoveNext
    Wend


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •