document.getElementById("date1").value传给值,为什么传不进去

Cquice 2013-05-24 10:20:30
为什么用 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>
...全文
168 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Cquice 2013-05-25
  • 打赏
  • 举报
回复
引用 2 楼 z284122755 的回复:

 <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>
谢谢了!
Cquice 2013-05-25
  • 打赏
  • 举报
回复
引用 1 楼 jslang 的回复:
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>
天际的海浪 2013-05-24
  • 打赏
  • 举报
回复
var abc=abc(); 明显是变量和函数重名了

87,922

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧