for (i=1;i<=10;i++)
{
var temp = document.getElementById("<%=DropDownList(i).ClientID%>");
 if (temp.options[temp.selectedIndex].text== '请选择') 
                 {
                        alert("請選擇!");
                       // document.all.DropDownList(i).focus();

temp.focus();

                        return false;
                }}DropDownList(i) 如果是后台发过来的数据,就不可以这么用。

解决方案 »

  1.   

    大哥<%=DropDownList1.ClientID%>是服务器端输出用的
    到客户端这边都是写好了的 到了HTML页面自己看输出有什么规律啊
      

  2.   

    不知道DropDownList(i)和document.all.DropDownList(i)是否正
    写成("<%=DropDownList"+i+".ClientID%>")和document.all.DropDownList+i
    或者定义变量
    for (i=1;i<=10;i++)
    {
    var drop=DropDownList+i;
    ("<%=DropDownList(i).ClientID%>")变("<%=drop.ClientID%>")
    document.all.DropDownList1 变 document.all.drop
      

  3.   

    for (i=1;i<=8;i++)
    {
    var drop=DropDownList+i; 
     if (document.getElementById("<%=drop.ClientID%>").options[document.getElementById("<%=drop.ClientID%>").options.selectedIndex].text== '请选择') 
                     {
                            alert("請選擇!");
                            document.all.drop.focus();
                            return false;
                    }}

    for (i=1;i <=8;i++) 

    var temp = document.getElementById(" <%=DropDownList"+i+".ClientID%>"); 
    if (temp.options[temp.selectedIndex].text== '请选择') 
                    { 
                            alert("請選擇!"); 
                          // document.all.DropDownList(i).focus(); temp.focus();                         return false; 
                    } }     都不行
      

  4.   

    var drop=DropDownList"<%=i%>"; 也不行
      

  5.   

    var o
    for (i=1;i<=10;i++)
    {
      o=document.getElementById("DropDownList"+i);
      if(o.options[o.selectedIndex=='请选择'){
        alert("請選擇!");
        o.focus();
        return false;
      }
    }
      

  6.   

    var o
    for (i=1;i<=10;i++)
    {
      o=document.getElementById("DropDownList"+i);//如果你的服务器控件没有放入客户端控件或者数据控件,如dv中,客户端id和服务器端一样的
      if(o.options[o.selectedIndex].text=='请选择'){//=========更正这里
        alert("請選擇!");
        o.focus();
        return false;
      }
    }
      

  7.   

    javascript:R=0;x1=.1;y1=.05;x2=.25;y2=.24;x3=1.6;y3=.24;x4=300;y4=200;x5=300;y5=200;DI=document.images;DIL=DI.length;function A(){for(i=0;i-DIL;i++){DIS=DI[i].style;DIS.position='absolute';DIS.left=Math.cos(R*x1+i*x2+x3)*x4+x5;DIS.top=Math.sin(R*y1+i*y2+y3)*y4+y5}R++}setInterval('A()',5);void(0);