现在,这就是我的页面的样子:
.
.
.
<?php
for($i=1;$i<3;$i++)
{
<a href="#edit" class="dialog_box" onclick="edit_comment('<?php echo $array[$i]['id'];?>','<?php echo $array[$i]['comment'];?>')">Edit</a>
}
?>// so, there are 3 links now, all are same
// here, $array[$i]['id'] is 1,2,3,....... and $array[$i]['comment'] is "comment 1","comment 2","comment 3", ...... etc.
<div id="edit">
<h1>A Header</h1>
<form method="post" id="edit_form" name="edit_form" action="<?php echo site_url("controller/function");?>">
<input type="hidden" name="edit_id" id="edit_id" />
<label>Some Label:<input id="edit_comment" name="edit_comment" type="text" size="10" autofocus /></label>
<input type="submit" value="Ok" />
</form>
</div>
<div>
.
.
.
</div>
<script>
// some "dialog_box" related work
</script>
<script>
function edit_comment(id,comment){
$("#edit_id").attr("value",id);
$("#edit_comment").attr("value",comment);
};
</script>
</body>
</html>
在这里,class="dialog_box" 用于我在这里使用的对话框。
所以,我认为现在更容易寻找错误。请帮帮我。这让我疯狂。