为什么用js生成单选框,IE浏览器无法选中

wang19841229 2007-08-25 10:56:13
我用js动态生成的单选框,用firefox浏览可以使用,但是用IE浏览时却无法选中不知道为什么
这是我的代码
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript">
window.onload = function()
{
for(var i = 0;i < 3;i++)
{
var form = document.getElementById("form");
var input = document.createElement("input");
input.setAttribute("type","radio");
input.setAttribute("name","answer");
if(i == 0)
{
input.setAttribute("checked",true);
}
form.appendChild(input);
}
}

</script>
</head>

<body >
<form id="form">

</form>
</body>
</html>
...全文
266 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
joohnnie 2007-08-25
  • 打赏
  • 举报
回复
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript">
window.onload = function()
{
for(var i = 0;i < 3;i++)
{

var form = document.getElementById("form");
if(i == 0){

var input = document.createElement("<input type='radio' name='answer' checked>");
}else{
var input = document.createElement("<input type='radio' name='answer' >");
}

form.appendChild(input);
}
}

</script>
</head>

<body >
<form id="form">

</form>
</body>
</html>

87,921

社区成员

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

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