我们HTML元素,这是我的网页看起来像:传递数据使用jQuery
.
.
.
<?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”是我在这里使用的对话框。
所以,现在我觉得它更容易寻找错误。请请帮助我。这让我疯狂。
对不起,这还不行。我尝试了所有的想法,但结果仍然相同。帮我。 – user2387319
我编辑了这个问题,请尝试再次帮助我。 – user2387319