I have a number of text-boxes which are created dynamically:
<?php
$columns = $_POST['n_cols'];
for ($i=0; $i<$columns; $i++) {
?>
<input type='text' id="autocol_<?php echo $i; ?>" name="autocol_<?php echo $i; ?>">
<?php
}
?>
Then I have a jQuery call to make these text-boxes behave as an auto-complete field:
<script type="text/javascript">
/*<![CDATA[*/
jQuery(function($) {
jQuery('#autocol_').autocomplete({'showAnim':'fold','select':function(event, ui) {
},'source':'/myproject/index.php?r=Controller/autocomplete&table=newtable'});
});
/*]]>*/
</script>
Is there a way in jQuery to use the above function to handle the autocomplete field for all the text-boxes that were dynamically created and have different ids? Something like jQuery will take all the text-boxes whose id start with ‘autocol’ and then manage the auto-complete function for all of them?
Thanks
Yes, there is such selector: