0
我有一個表有多個行和列,我不知道如何使用Jquery的自動完成插件,以便自動完成所選的行。它是表的代碼:自動完成JQuery多行
<table class="participante estilizar" id="participante_<?php echo $i?>" cellspacing="0" width="100%">
<tbody>
<tr>
<td>
<label for="cedula">Cédula</label><input class="cedula" onkeypress="return numeros(event)" type="text" maxlength="50" name="participante_cedula[]" value="<?php echo $value->cedula?>" />
</td>
<td>
<label for="nombre">Nombre y apellido</label><input class="nombre" onkeypress="return alfa(event)" type="text" maxlength="75" name="participante_nombre[]" value="<?php echo $value->nombre?>" />
</td>
<td>
<label for="correo">Correo</label><input class="correo" type="text" maxlength="50" name="participante_correo[]" value="<?php echo $value->correo?>" />
</td>
</tr>
</tbody>
</table>
我知道,我應該使用標籤ID,以確定我的表的每一行,但在這種情況下,我不知道該怎麼稱呼自動完成插件。它是自動完成代碼:
var sug_cedula = [
{
label: "123",
nombre: "Juan",
correo: "[email protected]"
},
{
label: "456",
nombre: "Pedro",
correo: "[email protected]"
},
{
label: "789",
nombre: "Angel",
correo: "[email protected]"
}
];
$(".cedula").autocomplete({
minLength: 0,
source: sug_cedula,
focus: function(event, ui) {
return false;
},
select: function(event, ui) {
$(".cedula").val(ui.item.label);
$(".nombre").val(ui.item.nombre);
$(".correo").val(ui.item.correo);
return false;
},
});
在我的例子,當我輸入一些字符,然後選擇一個選項,該功能自動填充具有相同值的所有表,因爲我使用的標籤類,而不是標籤ID。有人能幫助我嗎?
感謝您的幫助,的確是我的作品,我只需要前添加該代碼使用您的選項:'code' var thisRow = $(this).closest('tr'); – Angel 2014-10-05 23:47:43