日期:2014-05-16  浏览次数:20592 次

document.getElementById("date1").value传给<input id>值,为什么传不进去
为什么用 document.getElementById("type1").value=abc[0];
document.getElementById("date1").value=abc[1];
不能给   <input type="text"  name="type" id="type1" />
        <input type="text"  name="date" id="date1" />
传值啊!求指教啊!
<!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=utf-8" />
<title>Borser Detection</title>
<script type="text/javascript">
function abc(){
var s=["",""];
s[1]="123";
s[0]="11123";
  return s;
}
function bcd(){
var abc=abc();
  document.getElementById("type1").value=abc[0];
document.getElementById("date1").value=abc[1];
}
</script>
</head>
<body onload="bcd()">
   <input type="text"  name="type" id="type1" />

   <input type="text"  name="date" id="date1" />
</body>
</html>

------解决方案--------------------
var abc=abc();
明显是变量和函数重名了
------解决方案--------------------

 <script type="text/javascript">
 function bcd(){
 var a=abc();
 document.getElementById("type1").value=a[0];
 document.getElementById("date1").value=a[1];
 }
function abc(){
 var s=[];
 s[1]="123";
 s[0]="11123";
   return s;
 }
 </script>
 <body onload="bcd()">
    <input type="text"  name="type" id="type1" />
 
   <input type="text"  name="date" id="date1" />
 </body>