【发布时间】:2014-10-04 15:56:23
【问题描述】:
我有一个包含多行和多列的表,但我不知道如何使用 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: "juan@cuenta.com"
},
{
label: "456",
nombre: "Pedro",
correo: "pedro@cuenta.com"
},
{
label: "789",
nombre: "Angel",
correo: "angel@cuenta.com"
}
];
$( ".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。有人可以帮我吗?
【问题讨论】:
标签: javascript jquery autocomplete rows multiple-columns