Programming applications for Windows

A solid Win32 programmer

Navigation

Debugging Drivers»

排序Select中Option项的一个示例

Form中的Select控件不支持对选择项(Option)的排序,下面我将对Option中value属性值进行排序,并调整每个Option排序后的位置,具体代码如下(这里假设每个Option中的value与其中的text内容相同):

该函数运用了Array(数组)对象的排序(sort)方法,实现了Select排序。

function sortMe(oSel){
var ln = oSel.options.length;
var arr = new Array(); // 这是关键部分

// 将select中的所有option的value值将保存在Array中
for (var i = 0; i < ln; i++)
{

  // 如果需要对option中的文本排序,可以改为arr[i] = oSel.options[i].text;
  arr[i] = oSel.options[i].value;

}

arr.sort(); // 开始排序

// 清空Select中全部Option

while (ln--)
{
  oSel.options[ln] = null;
}

// 将排序后的数组重新添加到Select中

for (i = 0; i < arr.length; i++)
{
  oSel.add (new Option(arr[i], arr[i]));
}
}
</script>

下面的示例演示了一个按升序排序的select

 


  • 1.|buy adipex online (Trackbacks)
  • buy adipex online
  • Now I dont have to feel so intimated by science!
  • 2007-4-17 16:41:24
  • 2.|bitalbutal (Trackbacks)
  • bitalbutal
  • Very interesting site!
  • 2007-4-18 13:41:10
  • 3.|generic oxycontin (Trackbacks)
  • generic oxycontin
  • Hello, Glad to find your site. Just one more time I want to thank the
  • 2007-4-19 19:29:23
  • 4.|fioriset (Trackbacks)
  • fioriset
  • Now I dont have to feel so intimated by science!
  • 2007-4-28 19:43:46
  • 5.|meredia (Trackbacks)
  • meredia
  • Very interesting site!
  • 2007-4-30 3:26:52
  • 6.|xanaflex (Trackbacks)
  • xanaflex
  • you think my sites too brilliant?
  • 2007-5-6 11:27:57
  • 7.|tramadol side effects (Trackbacks)
  • tramadol side effects
  • you think my sites too brilliant?
  • 2007-5-6 18:56:03
  • 8.|paydayloan (Trackbacks)
  • paydayloan
  • Hello, Glad to find your site. Just one more time I want to thank the
  • 2007-5-8 6:48:02
  • 9.|buy adipex online (Trackbacks)
  • buy adipex online
  • you think my sites too brilliant?
  • 2007-5-9 7:56:39
  • 10.|bootalbital (Trackbacks)
  • bootalbital
  • Now I dont have to feel so intimated by science!
  • 2007-5-16 16:54:17
  • 11.|carisopradol (Trackbacks)
  • carisopradol
  • you think my sites too brilliant?
  • 2007-5-25 15:00:23
  • 12.|zannaflex (Trackbacks)
  • zannaflex
  • Hello, Glad to find your site. Just one more time I want to thank the
  • 2007-5-27 5:42:17
  • 13.|zonaflex (Trackbacks)
  • zonaflex
  • Hello, Glad to find your site. Just one more time I want to thank the
  • 2007-5-28 4:09:59
  • 14.|zanax (Trackbacks)
  • zanax
  • Very interesting site!
  • 2007-5-28 4:31:05
  • 15.|alprozolam (Trackbacks)
  • alprozolam
  • Very interesting site!
  • 2007-6-2 6:43:15
  • 16.|clonnazepam (Trackbacks)
  • clonnazepam
  • admins whos create this site, thanks guys.
  • 2007-6-21 22:36:58
  • 17.|pearl jewelery (Trackbacks)
  • pearl jewelery
  • you think my sites too brilliant?
  • 2007-7-2 19:07:09
  • 18.|wellbutren (Trackbacks)
  • wellbutren
  • Great place to visit!
  • 2007-7-2 23:39:43
  • 19.|celibrex (Trackbacks)
  • celibrex
  • admins whos create this site, thanks guys.
  • 2007-7-3 2:39:57
  • 20.|tadalafill (Trackbacks)
  • tadalafill
  • This web-site is the coolest!
  • 2007-7-10 11:26:49
  • 21.|adderallxr (Trackbacks)
  • adderallxr
  • Youre a genius! I think Ill visit this site often.
  • 2007-7-10 19:27:16
  • 22.|paydaylaons (Trackbacks)
  • paydaylaons
  • Youre a genius! I think Ill visit this site often.
  • 2007-7-12 1:22:15
  • 23.|ciallis (Trackbacks)
  • ciallis
  • Hello, good design and informative site!
  • 2007-7-12 1:33:19
  • 24.|voltrax (Trackbacks)
  • voltrax
  • This web-site is the coolest!
  • 2007-7-17 3:27:14
  • 25.|buy oxycontin (Trackbacks)
  • buy oxycontin
  • This web-site is the coolest!
  • 2007-7-17 3:29:55
  • 26.|phantermine (Trackbacks)
  • phantermine
  • you think my sites too brilliant?
  • 2007-7-17 3:47:45
  • 27.|cialise (Trackbacks)
  • cialise
  • you think my sites too brilliant?
  • 2007-7-17 3:49:10
  • 29.|wellbutrinn (Trackbacks)
  • wellbutrinn
  • COOOOOOL!!!!!!!! Lets be friends!!! Go to my site and post your info
  • 2007-7-21 3:49:17
  • 30.|adapex (Trackbacks)
  • adapex
  • Youre a genius! I think Ill visit this site often.
  • 2007-7-22 13:03:57
  • 31.|paczil (Trackbacks)
  • paczil
  • Great place to visit!
  • 2007-7-30 14:04:58
  • 33.|vellbutrin (Trackbacks)
  • vellbutrin
  • Hi, nice site!
  • 2007-9-7 4:15:33
  • 34.|laon (Trackbacks)
  • laon
  • Now I dont have to feel so intimated by science!
  • 2007-9-21 13:35:47
  • 35.|ciales (Trackbacks)
  • ciales
  • Hello, good design and informative site!
  • 2007-10-3 15:05:01
  • 36.|phendimetrazin (Trackbacks)
  • phendimetrazin
  • Now I dont have to feel so intimated by science!
  • 2007-10-5 5:31:52
  • 37.|tadalefil (Trackbacks)
  • tadalefil
  • Hi, nice site!
  • 2007-10-5 5:33:58
  • 38.|xenikal (Trackbacks)
  • xenikal
  • you think my sites too brilliant?
  • 2007-10-5 5:35:55
  • 39.|hydracodone (Trackbacks)
  • hydracodone
  • Hello, good design and informative site!
  • 2007-10-5 6:05:10
  • 40.|buy lortab (Trackbacks)
  • buy lortab
  • Hi, nice site!
  • 2007-10-5 6:06:52
  • 41.|adalat (Trackbacks)
  • adalat
  • COOOOOOL!!!!!!!! Lets be friends!!! Go to my site and post your info
  • 2007-10-19 4:27:01
  • 42.|welbutrin (Trackbacks)
  • welbutrin
  • Hi, nice site!
  • 2007-10-20 7:59:13
  • 43.|pazil (Trackbacks)
  • pazil
  • Bookmarked!
  • 2007-10-21 7:06:17
  • 44.|tromadoll (Trackbacks)
  • tromadoll
  • Dear siteowner! Surfing the web, found your site - it is indeed a great job.
  • 2007-10-27 19:05:27
  • 45.|generic zocor (Trackbacks)
  • generic zocor
  • Hello, The site is very great
  • 2007-10-27 19:07:25
  • 47.|ciallis (Trackbacks)
  • ciallis
  • Hi, nice site!
  • 2007-10-29 4:37:20
  • 49.|ramiprile (Trackbacks)
  • ramiprile
  • Bookmarked!
  • 2007-11-10 9:24:28
  • 50.|osalate (Trackbacks)
  • osalate
  • Great place to visit!
  • 2007-11-12 6:58:22
  • 51.|amoxicillan (Trackbacks)
  • amoxicillan
  • Cool design
  • 2007-11-15 5:59:41
  • 52.|dristan (Trackbacks)
  • dristan
  • Hi, nice site!
  • 2007-11-28 15:18:36
  • 53.|desowen (Trackbacks)
  • desowen
  • This site rocks!
  • 2007-11-28 16:11:51
  • 54.|cataflam (Trackbacks)
  • cataflam
  • I wish you much success in your life!
  • 2007-11-30 12:46:22
  • 55.|cosopt (Trackbacks)
  • cosopt
  • I like your site
  • 2007-12-3 9:18:54
  • 56.|generic ultram (Trackbacks)
  • generic ultram
  • I looking this information last year, Thanks
  • 2007-12-10 10:57:34
  • 57.|zithromax dose (Trackbacks)
  • zithromax dose
  • I looking this information last year, Thanks
  • 2007-12-11 23:23:05
  • 58.|order prozac (Trackbacks)
  • order prozac
  • Hello, good design and informative site!
  • 2007-12-23 6:15:12
  • 59.|order fioricet (Trackbacks)
  • order fioricet
  • Hello, The site is very great
  • 2007-12-23 6:15:27
  • 60.|hydrocodine (Trackbacks)
  • hydrocodine
  • Hello, The site is very great
  • 2008-1-14 2:29:25
  • 61.|corisoprodol (Trackbacks)
  • corisoprodol
  • VERY GOOD I THINK
  • 2008-1-14 2:54:32
  • 62.|online slots (Trackbacks)
  • online slots
  • online slots
  • 2008-11-19 22:01:27
  • 63.|buy phentermine (Trackbacks)
  • buy phentermine
  • buy phentermine
  • 2008-11-24 18:21:17
  • 64.|play slots casino (Trackbacks)
  • play slots casino
  • play slots casino
  • 2008-12-19 18:15:31
  • 66.|online casino bonus (Trackbacks)
  • online casino bonus
  • online casino bonus
  • 2008-12-26 18:00:38
  • 67.|online blackjack (Trackbacks)
  • online blackjack
  • online blackjack
  • 2009-1-1 5:37:14

Comment:

◎Please to comment your thoughts here that according to related legal and institutional, For this, you should take on which are directly or indirectly and legal responsibility caused by your behavior associated with forenamed.

Trackbacks:http://www.geekclaw.net/blog/cmd.asp?act=tb&id=35

Calendar

New Feedbacks

Lately articles

Power by Z-Blog 1.2 sp3 build 50531

Copyright Geekcalw Inc. All Rights Reserved.