function setchap(index, s1) { var i,j,k,txt; var cnum=new Array(50,40,27,36,34,24,21,4,31,24,22,25,29,36,10,13,10,42,150,31,12,8,66,52,5,48,12,14,3,9,1,4,7,3,3,3,2,14,4, 28,16,24,21,28,16,16,13,6,6,4,4,5,3,6,4,3,1,13,5,5,3,5,1,1,1,22); i=cnum[index]; var objchapter = document.getElementById("chapter"); var currentchapters = objchapter.options.length; if((i == 150) && (currentchapters < 150)) for(j = 1; j <= 150;j++) { txt = "第 " + j + " 篇"; objchapter.options[j-1] = new Option(txt, j); } else if((i < 150) && (currentchapters == 150)) { for(j = 1; j <= i; j++) { txt = "第 " + j + " 章"; objchapter.options[j-1] = new Option(txt, j); } for(j = 150;j > i;j=j-1) objchapter.options[j-1] = null; } else if (i > currentchapters) for(j = currentchapters; j <= i; j++) { txt = "第 " + j + " 章"; objchapter.options[j-1] = new Option(txt, j); } else if (i < currentchapters) for(j = currentchapters; j > i; j=j-1) objchapter.options[j-1] = null; objchapter.options[0].selected = s1; }