是这样的,我要从lins中提取第一列数据出来(这列数据为a01,a02,a03等等),然后点击该单元格则通过IFRAME弹出editi.php?id=a01;或editi.php?id=a02等等。如仅仅是弹出editi.php,我已经学会了,但是后面多了变量,又不会了。
我自己不懂,下面是我瞎写的,不对。还有,我希望iframe弹出时在屏幕的中央。该怎么办?
<body>
<table >
<tr>
<?php
include("IncDB.php");
$result=mysql_query("SELECT * FROM lins",$link);
$row=mysql_fetch_row($result);
while($row)
{echo "<td width='30' ; ondblclick='ed(\"".$row[0]."\")';>'编辑'</td>";//.$row[0]的数据为a01,a02,a03等等,点击该单元格则通过IFRAME弹出editi.php?id=a01;或editi.php?id=a02等等。
$row=mysql_fetch_row($result);
}
mysql_close($link);
?>
</tr>
</table>
<iframe src="editi.php?id=$row[0]" id="edit" style="height:250;width:450;top:'+(screen.height-250)/2+';left:'+(screen.width-450)/2';display:none" frameborder=1 marginwidth="0" marginheight="0" scrolling="no" z-index=999;></iframe>
<script type="text/javascript">
function ed(a){
var edit=('editi.php?id=''+a);
document.getElementById(edit).style.display="block";
}
</script>
</body>
------解决思路----------------------
function ed(a){
document.getElementById("edit").src="edit.php?id="+a;
}
------解决思路----------------------
你的程序能生成这样的 html 就不会有问题
<table >
<tr>
<td width='30' ondblclick='ed("a01")'>编辑</td>
<td width='30' ondblclick='ed("a02")'>编辑</td>
<td width='30' ondblclick='ed("a03")'>编辑</td>
</tr>
</table>
<iframe src="editi.php" id="edit" style="position:absolute;height:250;width:450; display:none" frameborder=1 marginwidth="0" marginheight="0" scrolling="no" z-index=999;></iframe>
<script type="text/javascript">
document.getElementById('edit').style.top = (screen.height-250)/2
document.getElementById('edit').style.left = (screen.width-450)/2
function ed(a){
document.getElementById('edit').src = 'editi.php?id='+a;
document.getElementById('edit').style.display="block";
}
</script>
</body>