I have several text boxes which I can associate only at run time with their unique ID's. I am trying to see if I can bind events to each of these text boxes (Create multiple bind events for the text box for which the ID is being passed through the array) at run time but this code does not work as I intended it to. The bind event does not fire when the text boxes are being typed in. Does anybody have any suggestion as to how this can be done.
//Populate the Name field with values from First name, Middle Initial, and Last name when they change
for (i = 0; i < strNameVariable.length; i++)
{
if (strNameVariable[i] != '')
{
var strFN = strNameVariable[i] + 'firstName'
var strMI = strNameVariable[i] + 'middleInitial'
var strLN = strNameVariable[i] + 'lastName'
$('#'+ strFN).bind('input', function ()
{
var nameArray = [$('#'+ strFN).val(), $('#'+ strMI).val(), $('#'+ strLN).val()];
$('#'+ strN).val(nameArray.join(' '));
});
}
}