我想在表格中创建一个ajax,但是当我尝试增加id="specificationName[' . $t . ']
时,它无法正常工作。
如果我不使用['。 $ t。 '],它有效,但如果我有3行,它只在第一行插入3输入,而不是在每一行。
谢谢
<script src="http://boutique/javascript/tokeninput/jquery.tokeninput.min.js"></script>
$products_specification_ajax = OSCOM::link('products_specification_ajax.php');
$t = 0;
while ($Qspecification->fetch()) {
$QspecificationName = $this->app->db->prepare('select specification_id,
language_id,
name
from :table_specification_description
where language_id = :language_id
and specification_id = :specification_id
');
$QspecificationName->bindInt(':language_id', $this->lang->getId());
$QspecificationName->bindInt(':specification_id', $Qspecification->valueInt('specification_id'));
$QspecificationName->execute();
$content .= '<td>
<script type="text/javascript">
$(document).ready(function() {
$("#specificationName[' . $t . ']").tokenInput("' . $products_specification_ajax . '" ,
{
tokenLimit: 1,
resultsLimit: 5,
onResult: function (results) {
$.each(results, function (index, value) {
value.name = value.id + " " + value.name;
});
return results;
}
});
});
</script>
' . HTML::inputField('specification_name[' . $t . ']', $specification_name, 'class="token-input" id="specificationName[' . $t . ']"') . '</td>';
$t++;
}