| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 524 人关注过本帖
标题:一个关于js下拉菜单的问题
只看楼主 加入收藏
爱心流沙
Rank: 1
等 级:新手上路
帖 子:10
专家分:7
注 册:2010-10-20
结帖率:0
收藏
已结贴  问题点数:20 回复次数:2 
一个关于js下拉菜单的问题
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>

<title>ex1</title>
<style type="text/css">
 *{margin:0}
body {text-algin:center;min-width:760px}
div{padding:3px 3px 3px 3px}
#main {width:720px;margin:0 auto;text-algin:left;margin-top:30px}
</style>
        <link type="text/css" rel="stylesheet" href="style1.css" id="style1" title="蓝色风格" />
        <link type="text/css" rel="stylesheet" href="style2.css" id="style2" title="红色风格" />
        <link type="text/css" rel="stylesheet" href="style3.css" id="style3" title="灰色风格" />
   
    <link type="text/css" rel="stylesheet" href="style4.css" id="style4" title="字体小" />
    <link type="text/css" rel="stylesheet" href="style5.css" id="style5" title="字体中" />
    <link type="text/css" rel="stylesheet" href="style6.css" id="style6" title="字体大" />
<script type="text/javascript">

function setCSS(){
            setColor($("setColor").value);
            setSize($("setFontSize").value);
        }
        
        function $(id){
            return document.getElementById(id);
        }
        
        function setColor(color){
            $("style1").disabled = true;
            $("style2").disabled = true;
            $("style3").disabled = true;
            
            $(color).disabled = false;
        }
        
        function setSize(size){
            $("style4").disabled = true;
            $("style5").disabled = true;
            $("style6").disabled = true;
            
            $(size).disabled = false;
        }
function SetCookie(cookName,cookieValue,nDays){
  var today=new Date();
  var expire=new Date();
  if(nDay==null||nDays==0) nDay=1;
     expire.setTime(today.getTime()+3600000*24*nDay);
  document.cookie=cookieName+"="+escape(cookieValue)+"expires="+expire.toGETString();
}
function login(){
  var username=$("user").value;
  var password=$("pass").value;
  var save=$("save").checked;
if(username=="test"&&password="password"){
   if(save) SetCookie("username",username,7);
      else Setcookie("username",username,1);
 document.location="ex2.html";
}
else{
alert("用户名错误!");
  }
}
function $(id){
  return document.getElementById(id);
}
</script>

</head>

<body>
<table border="0">
  <tr>
    <td>&nbsp;</td>
    <td><select id="setColor">
            <option value="0">阅读底色</option>
            <option value="style1">蓝色</option>
            <option value="style2">红色</option>
            <option value="style3">灰色</option>
        </select>
        <select id="setFontSize">
            <option value="0">字体大小</option>
            <option value="style4">小</option>
            <option value="style5">中</option>
            <option value="style6">大</option>
        </select>
        <input type="button" id="set" value="设置提交" onClick="setCSS();" />
    </td>
  </tr>
  <div id="main">
     <div>
        <span>用户名:</span><input type="text" id="user" /></div>
     <div>
        <span>密码:</span><input type="password" id="pass" /></div>
       7天无需登录
         <input type="button" onclick="login()" value="登录"/>
         <input type="button" onclick="register()" value="注册"/></div>
 </div>

</table>
</body>
</html>
为何不能用,看看还有什么问题要改正
搜索更多相关主题的帖子: 菜单 
2010-11-25 15:47
elan1986
Rank: 6Rank: 6
等 级:贵宾
威 望:18
帖 子:458
专家分:407
注 册:2007-12-17
收藏
得分:20 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>

<title>ex1</title>
<style type="text/css">
*{margin:0}
body {text-algin:center;min-width:760px}
div{padding:3px 3px 3px 3px}
#main {width:720px;margin:0 auto;text-algin:left;margin-top:30px}
</style>
        <link type="text/css" rel="stylesheet" href="style1.css" id="style1" title="蓝色风格" />
        <link type="text/css" rel="stylesheet" href="style2.css" id="style2" title="红色风格" />
        <link type="text/css" rel="stylesheet" href="style3.css" id="style3" title="灰色风格" />
   
    <link type="text/css" rel="stylesheet" href="style4.css" id="style4" title="字体小" />
    <link type="text/css" rel="stylesheet" href="style5.css" id="style5" title="字体中" />
    <link type="text/css" rel="stylesheet" href="style6.css" id="style6" title="字体大" />
<script type="text/javascript">

function setCSS(){
            setColor($("setColor").value);
            setSize($("setFontSize").value);
        }
        
        function $(id){
            return document.getElementById(id);
        }
        
        function setColor(color){
            $("style1").disabled = true;
            $("style2").disabled = true;
            $("style3").disabled = true;
            
            $(color).disabled = false;
        }
        
        function setSize(size){
            $("style4").disabled = true;
            $("style5").disabled = true;
            $("style6").disabled = true;
            
            $(size).disabled = false;
        }
function SetCookie(cookName,cookieValue,nDays){
  var today=new Date();
  var expire=new Date();
  if(nDay==null||nDays==0) nDay=1;
     expire.setTime(today.getTime()+3600000*24*nDay);
  document.cookie=cookieName+"="+escape(cookieValue)+"expires="+expire.toGETString();
}
function login(){
  var username=$("user").value;
  var password=$("pass").value;
  var save=$("save").checked;
  
  if(username == '' || password == ''){
    alert('请录入用户名或密码');
    return;
  }
  
  
  if(username == '1' && password == '1'){
    if(save) SetCookie("username",username,7);
      else Setcookie("username",username,1);
  }else{
    alert("用户名错误!");
  }
  /*
  if(username=="test" && password="password"){
   if(save) SetCookie("username",username,7);
      else Setcookie("username",username,1);
    document.location="ex2.html";
}else{
    alert("用户名错误!");
  }
  */
}

function register(){
   
}
function $(id){
  return document.getElementById(id);
}
</script>

</head>

<body>
<table border="0">
  <tr>
    <td>&nbsp;</td>
    <td><select id="setColor">
            <option value="style1" checked>蓝色</option>
            <option value="style2">红色</option>
            <option value="style3">灰色</option>
        </select>
        <select id="setFontSize">
            <option value="style4" checked>小</option>
            <option value="style5">中</option>
            <option value="style6">大</option>
        </select>
        <input type="button" id="set" value="设置提交" onClick="setCSS();" />
    </td>
  </tr>
  <div id="main">
     <div>
        <span>用户名:</span><input type="text" id="user" /></div>
     <div>
        <span>密码:</span><input type="password" id="pass" /></div>
      <input type="checkbox" id="save"> 7天无需登录
         <input type="button" onclick="login();" value="登录"/>
         <input type="button" onclick="register();" value="注册"/></div>
</div>

</table>
</body>
</html>
2010-11-25 16:22
爱心流沙
Rank: 1
等 级:新手上路
帖 子:10
专家分:7
注 册:2010-10-20
收藏
得分:0 
为什么要这样呢
2010-11-25 16:46
快速回复:一个关于js下拉菜单的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.050653 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved