<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>测试</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<script>
function abc(obj){
  if(obj.value==2){
abc_v.innerHTML="上海";
  }else{
    abc_v.innerHTML="天津";
  }
}
</script>
</head>
<body>
<form name="form1"  onsubmit="return check_form()"> <select id="AA" name="AA" onchange="abc(this)">
<option value="1" selected>天津</option>
<option value="2">上海</option>
</select></form>
<span id="abc_v">天津</span>
</body>
</html>
上面的js触发,因为加载了第1行的声明语句,在FF下无法触发
在网上找了很长时间 找到一篇相关的文章
http://www.cqzol.com/fabrication/Javascript/200806/174846.html却无法解决我的问题有经验的朋友,帮我改一下js触发代码,不删第一行的声明同时能触发js.谢谢大家

解决方案 »

  1.   

    <script>
    function abc(obj){
      if(obj.value==2){
        document.getElementById("abc_v").innerHTML="上海";
      }else{
        document.getElementById("abc_v").innerHTML="天津";
      }
    }
    </script>
      

  2.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>测试</title>
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
    <script>
    function abc(obj){
      if(obj.options[obj.selectedIndex].value==2){
        document.getElementById("abc_v").innerHTML="上海";
      }else{
        document.getElementById("abc_v").innerHTML="天津";
      }
    }
    </script>
    </head>
    <body>
    <form name="form1"  onsubmit="return check_form()">        <select id="AA" name="AA" onchange="abc(this)">
                <option value="1" selected>天津</option>
                <option value="2">上海</option>
            </select></form>
    <span id="abc_v">天津</span>
    </body>
    </html>
      

  3.   

    两位的方法 在FF下没问题
    但在IE6下 就不灵了。
      

  4.   

    准确讲是 innerHTML 反应速度很慢。