hi,
i'm trying to manipulate dynamic textboxes using jquery such that when the value of the textbox_1 is, say, 'abcd' a new text box textbox_2 would be introduced and when the value of textbox_2 is again 'abcd' a third one is introduced and so on. ive managed to do this with the following code, but with a little problem.
$(document).ready(function(){
var cnt = 1;
$("#inpu_"+cnt).keyup(function () {
var value = $("#inpu_"+cnt).val();
if(value == 'abcd'){
$("#inpu_"+cnt).css("background-color", "red");
cnt = cnt + 1;
$("#content").append('<input type="text" id="inpu_' + cnt + '" />');
}
});
}).keyup();
the problem is that although textbox_2 is displayed instantaneously, the 3rd and 4th does not when the value of textbox_2 is 'abcd'. but they are displayed as soon as a key is pressed in the original textbox (textbox_1). that is the 3rd one is displayed when textbox_2's value is 'abcd' and a key is pressed while inside textbox_1. and so on.
[edit 1] btw, inside body tag ive created a div and given the id content. and inside it is the textbox_1 with the id 'inpu_1'. the original one that is.
what could be the problem? what am i doing wrong?
thanks in advance for ur help.