document.dynamiccombo .stage2
                     ^ 这里好象多了一个空格在浏览器里直接右键查看网页源代码,看看这个控件在浏览器的具体name,对应好就不会错了

解决方案 »

  1.   

    TO:
    meizz(梅花雪)查了一下源文件,为何变成这样
    <form name="_ctl0" method="post" action="combo box.aspx" id="_ctl0">
      

  2.   

    没错,即使多了个空格也不提示错的。把它输出,试一下:
    <form name="dynamiccombo" method="post" runat="server">
    <select name="stage2" size="0" onchange="displaysub()">
    <option value="#1" selected>this is a place</option>
    <option value="#2">this is a place</option>
    <option value="#3">this is a place</option>
    <option value="#4">this is a place</option>
    </select>
    <input type="button" name="btgo" value="GO!" onclick="gothere()">
    </form>
    <script language="javascript">
    function gothere()
    {
    var cacheobj=document.dynamiccombo .stage2 ;
    alert(cacheobj.value);
    }
    </script>
      

  3.   

    <form name="dynamiccombo" method="post" runat="server">
    <select name="stage2" size="0" onchange="displaysub()">
    <option value="#1" selected>this is a place</option>
    <option value="#2">this is a place</option>
    <option value="#3">this is a place</option>
    <option value="#4">this is a place</option>
    </select>
    <input type="button" name="btgo" value="GO!" onclick="gothere()">
    </form>
    <script language="javascript">
    function gothere()
    {
    var cacheobj = document.dynamiccombo.stage2;
    alert(cacheobj.value);
    }
    function displaysub()
    {
    var cacheobj = document.dynamiccombo.stage2;
    alert(cacheobj.value);
    }
    </script>
      

  4.   

    只是多了一个空格。
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    </head><body>
    <form name="dynamiccombo" method="post" runat="server">
    <select name="stage2" size="0" onchange="displaysub()">
    <option value="#" selected>this is a place</option>
    <option value="#">this is a place</option>
    <option value="#">this is a place</option>
    <option value="#">this is a place</option>
    </select>
    <input type="button" name="btgo" value="GO!" onclick="gothere()">
    </form>
    <script language="javascript">
    var cacheobj=document.dynamiccombo.stage2 
    </script>
      

  5.   

    对了,如果你的IE版本小于5 那么:
    <script id=clientEventHandlersJS language=javascript>
    <!-- // 此处必须加上固定字符。function document_onclick() {}//-->
    </script>
      

  6.   

    谢谢楼上几位!不过都没有解决!问题在于:在源代码中<form name="dynamiccombo" method="post" runat="server">
    可运行后查看源文件却成了<form name="_ctl0" method="post" action="combo box.aspx" id="_ctl0">
    可能是因为这个,当然document.dynamiccombo.stage2 会为空对象,可又不知道为什么为变成这样?能帮我解释一下
      

  7.   

    还有就是:document.dynamiccombo .stage2 这句话中有没有空格都是一样的
      

  8.   

    你啊runat="server"去掉试试, 应该不会有问题. 还要就是你的httpserver是什么, 如果runat="server",你直接打开html文件和通过http方式打开是不一样的.