<!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>
<script type="text/javascript">
function changeitem(){ 
    s="1,fgdfg";
var s= new array();
s=s.split(",");
document.getElementById("aa").value=s[0];
document.getElementById("bb").value=s[1];
}
</script>
</head>
<body>
<input type="text" name="aa" id="aa" />   
<input type="text" name="bb" id="bb" />
<input type="button" name="button1" value="提交"  onclick="changeitem()"/>
</body>
</html>
这样写错了吗?为什么没有运行结果,

解决方案 »

  1.   

    s="1,fgdfg";
    var s= new array(); 
    你都写s做什么 。
      

  2.   

    //var s= new array(); 这句不要
      

  3.   


    <!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>
    <script type="text/javascript">
    function changeitem(){  
    s="1,fgdfg"; // 字符串
    //var s= new array(); 这行多余
    s = s.split(","); //split就使s为数组了,所以上面多余。
    document.getElementById("aa").value=s[0]; 
    document.getElementById("bb").value=s[1];
    }
    </script>
    </head>
    <body>
    <input type="text" name="aa" id="aa" />   
    <input type="text" name="bb" id="bb" />
    <input type="button" name="button1" value="提交" onclick="changeitem()"/>
    </body>
    </html>
      

  4.   


    <!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>
    <script type="text/javascript">
    function changeitem(){    
    var s = new Array("1", "fgdfg"); 
    document.getElementById("aa").value=s[0];
    document.getElementById("bb").value=s[1];
    }
    </script>
    </head>
    <body>
    <input type="text" name="aa" id="aa" />    
    <input type="text" name="bb" id="bb" />
    <input type="button" name="button1" value="提交" onclick="changeitem()"/>
    </body>
    </html>