Hi.
i got table A(contact-names) which is where name are populated to from db and table B(guest-names) where names from table A will be appended to.
this is the js i came up with to append the names:
var msg2 = '<tr class="tr"><td><input type="text" name="GName" class="input-name" placeholder="Doubleclick on a name." size="40" readonly></td></tr>';
$('.contact-names').load('/EMS2/showUser.php');
$(".guest-names").append(msg2);
$(".contact-names tr").live("dblclick", function(){
var name = $(this).text();
$(".input-name").val(name);
$(".tr").append(msg2);
$(this).empty();
});
as u can c the doubleclick function is missing something.
as of right now the name does append into the text box and also appends a second text box under the first (good). but then if i doubeclick on a second name it fills the first textbox as well as the second one and adds 2 empty textbox instead of just one. this is what im trying to get my head around.
i think i need to use .each() to find the next empty text box and fill that in and then add a text box or something along those lines.
maybe :
$(".contact-names tr").live("dblclick", function(){
var name = $(this).text();
$(".tr).each(function()
{
//maybe something like: ,not sure
if($(this).find(":empty").val() == "")
{
$(".input-name").val(name);
$(".tr").append(msg2);
$(this).empty();
}
});
});
TIA!