我这里有比较容易看懂的一种解法,你看行不行?
字符串之间用“|”分开的 
var i=0;
 var fgf="|";
 var filelist;
 var thetotallist="one|two|three|four|five|six|seven|eight|nine|ten|";
 while(num!=-1)
 {
  var num=thetotallist.indexOf(fgf);
  if(num==-1)
  {
    filelist=thetotallist;
    thetotallist="";
  }
  filelist=thetotallist.substring(0,num);
  form1.select1.options[i]=new Option(filelist); 
  thetotallist=thetotallist.substring(num+1);
  i++;
 } 

解决方案 »

  1.   

    哈哈,难道你们没有使用过split吗?
    <HTML>
    <HEAD>
    <TITLE>Sample</TITLE>
    </HEAD>
    <BODY bgColor="white">
    <CENTER>
    <H1>TEST</H1>
    </CENTER>
    <TABLE BORDER="1">
    <SCRIPT Language="JavaScript">
    <!--
    moji = "Welcome to JavaScript World";
    document.write("<TR><TD colspan='2'>原文字列:",moji,"</TD></TR>");
    str = moji.split(" ");
    str2 = moji.split(" ");
    for (i in str) document.write("<TR><TD>变换后文字列 [",i,"]</TD><TD>",str[i],"</TD></TR>");
    document.write("<HR><TR><TD>,分割</TD><TD>",str2,"</TD></TR>");
    // -->
    </SCRIPT>
    </TABLE>
    </BODY>
    </HTML>