I can't put autocomplete working with dynamic textboxs. I have a
javascript function to add dynamic textboxs, but when i attach the
autocomplete function to the dynamic textboxs, it doenst work.

Some work that might help this issue:

// Javascript function that adds dynamicly textboxs

var initial_count = new Array();
var rows_limit = 5; // Set to 0 to disable limitation

function addRow(table_id)
{
        var tbl = document.getElementById(table_id);
        // counting rows in table
        var rows_count = tbl.rows.length;
        if (initial_count[table_id] == undefined)
        {
                // if it is first adding in this table setting initial rows 
count
                initial_count[table_id] = rows_count;
        }
        // determining real count of added fields
        var tFielsNum =  rows_count - initial_count[table_id];
        if (rows_limit!=0 && tFielsNum >= rows_limit) return false;
        var input = '<input class="text_area" type="text" name="author[]"
id="bla" size="70" maxlength="250"/>';
        var remove= '<input type="button" value="-" onclick="removeRow
(\''+table_id+'\',this.parentNode.parentNode)"/>';

        try
        {
                var newRow = tbl.insertRow(rows_count);
                var newCell = newRow.insertCell(0);
                newCell.innerHTML = input;
                var newCell = newRow.insertCell(1);
                newCell.innerHTML = remove;
        }
        catch (ex) {
                //if exception occurs
                alert(ex);
        }
}

// Button that adds textboxs dynamicly
<input type="button" name="Button" value="+" onClick="addRow
('authorsTable')" />

// Jquery autocomplete function call

$(document).ready(function()
{
        $("#bla").autocomplete(cities);
});

NOTICE: I already have this working with fixed textboxs, the only
problem is with dynamicly added textboxs. Thanks

Reply via email to