<select name="Year" size=1 >
<% 
  dim i
  for i=1900 to 2050
        response.write "<option value=" & i & ">" & i &"</option>"
  next
 %>
</select>
<script language=javascript>
document.all.Year.value="<%=Year%>";
</script>

解决方案 »

  1.   

    你到底要做什么?
    option里面写value不就可以了!
    提交的时候,服务器端就会得到这个value值如果是检测变化,在select里面加上onchange事件通过var y = Year.options[Year.selectedIndex].value就可以获得改变复选框的value值,估计你要的是第二个吧!
      

  2.   

    当你选种下拉列表后,提交后就可以用
    jsp中:String a=request.getParameter("Year");在html中,你可以:
    document.forms[0].Year.options[selectedIndex].value
    得到下拉列表的值。
      

  3.   

    不懂你的复选框是指select还是input type=checkbox如果是服务端取:selcet 直接Request.Form("Year")
    客户端取select可以是
    xxxx=document.all.Year(document.all.Year.selectedIndex).value
      

  4.   

    或者这样做:<select name="Year" size=1 >
    <% 
    dim i,s
    s=""
    iYear=2000
    for i=1900 to 2050
    if iYear=i then 
    s=" selected "
    else 
    s=""
    end if
    response.write "<option value=" & i & s & ">" & i &"</option>"
    next
     %>
    </select>
      

  5.   

    另:Year是一个关键字,不能当变量用。
      

  6.   

    <html>
    <head>
    <script language="javascript">
    <!--
    function test_onclick()
    {
    var i = document.forms[0].elements[0].selectedIndex;
    alert(document.forms[0].Year.options[i].value);
    }
    -->
    </script>
    </head><body>
    <form name="myForm">
    <select name="Year">
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    </select>
    <input type="button" name="test" value="test" onclick="test_onclick()">
    </form>
    </body>
    </html>