Response title
This is preview!
this is my jquery mode
function split( val ) { return val.split( /,\s*/ ); } function extractLast( term ) { return split( term ).pop(); } $( "#mag_autocomplete" ).autocomplete({ multiple: true, source: "Functions/autocomplete.php?cat=mag_type", minLength: 2, select: function( event, ui ) { log(ui.item.value,ui.item.id); var terms = split( this.value ); // remove the current input terms.pop(); // add the selected item terms.push( ui.item.value ); // add placeholder to get the comma-and-space at the end terms.push( "" ); this.value = terms.join( "," ); return false; } });
and this is my html code
<tr> <td>*Damage: </td><td><input id="damage_ac" type="text" value="" name="damage" title="Damage of the weapon e.g. 7999" /></td> </tr><tr> <td>*Mag Type(s): </td><td><input value="" id="mag_autocomplete" class="ui-autocomplete-input" name="mag_types" title="Magazine types which gun uses e.g. STANAG Mag. If there is more than 1 mag types please seperate them using Comma(,)" /></td> </tr><tr> <td>Ammo Type(s): </td><td><input id="ammo_ac" type="text" value="" name="ammo_type" title="Ammo types of the gun e.g. 5.56x45mm. which is ammo type of M16A2. seperate ammo types with comma(,)" /></td> </tr>
and here is my problem. why this is not working
function split( val ) { return val.split( /,\s*/ ); } function extractLast( term ) { return split( term ).pop(); } $( "#mag_autocomplete, #damage_ac, #ammo_ac" ).autocomplete({ multiple: true, source: "Functions/autocomplete.php?cat=" + $(this).attr("name"), minLength: 2, select: function( event, ui ) { log(ui.item.value,ui.item.id); var terms = split( this.value ); // remove the current input terms.pop(); // add the selected item terms.push( ui.item.value ); // add placeholder to get the comma-and-space at the end terms.push( "" ); this.value = terms.join( "," ); return false; } });
$(this).attr("name") returns unidentified
why this is happening?
© 2013 jQuery Foundation
Sponsored by and others.