<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head> <title>My JSP 'a.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page"> </head>
<body>
<select name="aa">
<option value=1>
公开
</option>
<option value=2>
不公开
</option>
<option value=3>
仅向好友公开
</option>
</select>
<script language="javascript">
alert(s.options[1].selected=true);
aa.options[1].selected=true
</script>
</body>
</html>
这里应该显示不公开的啊 可是还是显示公开 请问什么问题

解决方案 »

  1.   

    <option value=2 selected="selected">
      不公开
    </option>
    这样也可以啊,为什么一定要用脚本呢
      

  2.   

    <html>
        <head>        <title>My JSP 'a.jsp' starting page</title>        <meta http-equiv="pragma" content="no-cache">
            <meta http-equiv="cache-control" content="no-cache">
            <meta http-equiv="expires" content="0">
            <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
            <meta http-equiv="description" content="This is my page">    </head>
        <body>
            <select name="aa" id='aa'>
                <option value=1>
                    公开
                </option>
                <option value=2>
                    不公开
                </option>
                <option value=3>
                    仅向好友公开
                </option>
            </select>
            <script language="javascript">     
                document.getElementById("aa").options[1].selected=true
        </script>
        </body>
    </html>
      

  3.   

    <script language="javascript">
                alert(s.options[1].selected=true);        
                aa.options[1].selected=true
        </script>看你的脚本,alert(s.options[1].selected=true);        
    请问 s 是什么东西啊,应该在这句就报错了,所以下面都没执行
      

  4.   


           <script language="javascript">    
                aa.options[1].selected="selected";
           </script>