Adding text to input with ajax then selecting that text
I am trying to select the text in an input type = text after a get ajax call inserts data into that field using the on focus event. The ajax part works fine but the text isn't selected. If I tab out and back into the field the text gets selected then. Any idea how to make this work. Here is the code...
$("#name").focus(
function()
{
CallSign = $("input[name=CallSign]").val();
$.get("CallSignTable.php", {f: "name", CallSign: CallSign},
function(data){
$("#name").val(data);
});
$("#name").select();
}
)
I have tried this.select() and it doesn't work the way I need it to either.
Thanks,
Chris W