在我的页面上,我有很多表单,在女巫字段中,ID 是基于 DB id 生成的。像这样:
<input type="hidden" name="id" value="<?php echo (isset($content))?$content->getId():''?>" />
<input type="hidden" id="x<?php echo $content->getId()?>"/>
<input type="hidden" id="y<?php echo $content->getId()?>"/>
<input type="hidden" id="x2<?php echo $content->getId()?>"/>
<input type="hidden" id="y2<?php echo $content->getId()?>"/>
这为我提供了所有形式的唯一 ID。现在我在 jquery 框架中有 Javascript 函数,它设置了不起作用的指定字段的值:
$(function(){
$('#jcrop_target_id<?php echo $content->getId()?>').Jcrop({
onSelect: updateCoords
});
});
function updateCoords(c)
{
$('#x<?php echo $content->getId()?>').val(c.x);
$('#y<?php echo $content->getId()?>').val(c.y);
$('#x2<?php echo $content->getId()?>').val(c.x2);
$('#y2<?php echo $content->getId()?>').val(c.y2);
};
值 c.* 可以,但显然#x<?php echo $content->getId()?>
不起作用。正确的方法是什么?问候。