![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi all, I have a drop down box that lists data from adatabase and it works well but I would like the data to be sorted on alpha. I could change the datasource to look at a view that is alpha sorted but i'd like to know if there is a way to do this in DWMX ? Any ideas ? Mitch... Demo: http://mickweb.com/javascript/demo/sortMenu.html |
#3
| |||
| |||
|
|
VegaLA wrote: Hi all, I have a drop down box that lists data from adatabase and it works well but I would like the data to be sorted on alpha. I could change the datasource to look at a view that is alpha sorted but i'd like to know if there is a way to do this in DWMX ? Any ideas ? Mitch... Demo: http://mickweb.com/javascript/demo/sortMenu.html You can do using javascript, the following sorts the labels(text): script type="text/JavaScript" function sortMenuAlpha(x,y){ A=x[0];B=y[0]; return A>B?1:A<B?-1:0 } function alphaMenu(menu,headerInPlace){ t=headerInPlace?+1:+0,a=new Array(); for(var i=t;i<menu.length;i++){ a[a.length]=[menu.options[i].text,menu.options[i].value] } a.sort(sortMenuAlpha); menu.options.length=t for(var j=t,k=0;j<=a.length;j++){ menu.options[j]=new Option(a[k][0],a[k][1]) k++ } } /script body onload="alphaMenu(document.forms[0].mu,true)" form action="" method="get" select name="mu" option value="Select" selected>Select</option option value="pet">cat</option option value="anteater">aardvark</option option value="caver">bat</option option value="meat">chicken</option option value="insect">ant</option option value="predator">bear</option /select /form Mick |
#4
| |||
| |||
|
#5
| |||
| |||
|
|
i am posting here as part of an assingment for a multimedia course i am going i have to copy a reply into my assingnment if some one would be kind enough to reply i would be much obliged. |
#6
| |||
| |||
|
|
But it'd be better to do it in the recordset. -- Murray --- ICQ 71997575 Team Macromedia Volunteer for Dreamweaver (If you *MUST* email me, don't LAUGH when you do so!) ================== http://www.dreamweavermx-templates.com - Template Triage! http://www.projectseven.com/go - DW FAQs, Tutorials & Resources http://www.dwfaq.com - DW FAQs, Tutorials & Resources http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes ================== "Mick White" <mwhite13BOGUS (AT) rochester (DOT) rr.com> wrote in message news:cmubpq$jh7$1 (AT) forums (DOT) macromedia.com... VegaLA wrote: Hi all, I have a drop down box that lists data from adatabase and it works well but I would like the data to be sorted on alpha. I could change the datasource to look at a view that is alpha sorted but i'd like to know if there is a way to do this in DWMX ? Any ideas ? Mitch... Demo: http://mickweb.com/javascript/demo/sortMenu.html You can do using javascript, the following sorts the labels(text): script type="text/JavaScript" function sortMenuAlpha(x,y){ A=x[0];B=y[0]; return A>B?1:A<B?-1:0 } function alphaMenu(menu,headerInPlace){ t=headerInPlace?+1:+0,a=new Array(); for(var i=t;i<menu.length;i++){ a[a.length]=[menu.options[i].text,menu.options[i].value] } a.sort(sortMenuAlpha); menu.options.length=t for(var j=t,k=0;j<=a.length;j++){ menu.options[j]=new Option(a[k][0],a[k][1]) k++ } } /script body onload="alphaMenu(document.forms[0].mu,true)" form action="" method="get" select name="mu" option value="Select" selected>Select</option option value="pet">cat</option option value="anteater">aardvark</option option value="caver">bat</option option value="meat">chicken</option option value="insect">ant</option option value="predator">bear</option /select /form Mick |
#7
| |||
| |||
|
|
I agree. It's too easy to sort the data in the recordset, and then simply write the options out in a loop. It requires all of 3 lines of code after the ORDER BY command is used in the select statement. It's better to let the server order the recordset than to use client-side resources to simply sort a listbox. It's easy using JS, too. |
![]() |
| Thread Tools | |
| Display Modes | |
| |