我想用唯一的id动态创建div ..基于id我们需要从数据库中获取值..但这里可以得到id但是divTag.innerHTML = 没有获取id来执行我的SQL查询 请帮帮我 谢谢adnvce
.dynamicDiv {
width:200px;
height:100px;
border:solid 1px #c0c0c0;
background-color:#e1e1e1;
font-size:11px;
font-family:verdana;
color:#000;
padding:5px;
}
.dynamicDiv{ float:left;}
</style>
<script type="text/javascript" language="javascript">
function createDiv($id)
{
var id =$id;
var divTag = document.createElement("div");
var id =$id;
divTag.id = "div1";
divTag.setAttribute("align","center");
divTag.style.margin = "100px auto";
divTag.className ="dynamicDiv";
divTag.innerHTML = "<?php $sql =mysql_query("SELECT * FROM TABLE WHERE ID='$id'");
$res = mysql_fetch_array($sql);
print_r($res);
?>";
document.body.appendChild(divTag);
}
</script>
</head>
<body style="float:left;">
<div style="float:left;">
<b>Click this button to create div element dynamically</b>
<input id="btn1" type="button" value=
"create div" onClick="createDiv('<?php echo rand(); ?>');" />